Apologies for the basic question, but I can't figure it out. I'm very,very new to Mathematica and programming.

So I have two waves of data, first wave has 15 countries and 9 variables, wave 2 has 20 countries and also 9 variables. I defined tables for all the variables and defined the model-output as position of that table like so: netwealth1[[1]] etc. This works and the tables carry all the observations.

What I want to do visualise a table of variables by country of both waves of data together. I tried this:

defined a list of variables for both waves:

listofvariables = {paretostart1, paretostart2, alphawave1, alphawave2, 
   netwealthtotal1, netwealthtotal2, corrnetwealthtotal1, corrnetwealthtotal2, 
   oversamplingrate1, oversamplingrate2, percsharestop11, percsharestop12, 
   corrpercsharestop11, corrpercsharestop12, avwealth1, avwealth2, corravwealth1, 

define labels:

labelsvariablen = {"Paretostart Wave I", "Paretostart Wave II", 
   "Pareto-Alpha Wave I", "Pareto-Alpha Wave II", "Total Net Wealth Wave I", 
   "Total Net Wealth Wave II", "Corrected Net Wealth Wave I", 
   "Corrected Net Wealth Wave II", "Oversamplingrate Wave I", 
   "Oversamplingrate Wave II", "Wealth-share Top Percentile Wave I", 
   "Wealth-share Top Percentile Wave II", 
   "Corrected Wealth-share Top Percentile WaveI", 
   "Corrected Wealth-share Top Percentile Wave II", "Average Wealth Wave I", 
   "Average Wealth Wave II", "Corrected Average Wealth Wave I", 
   "Corrected Average Wealth Wave II"};

labelscountries = {"Austria", "Belgium", "Cyprus", "Germany", "Spain", "Finnland", 
   "France", "Greece", "Italy", "Luxembourg", "Malta", "Netherlands", "Portugal", 
   "Slovenia", "Slovakia", "Estonia", "Hungary", "Ireland", "Latvia", "Poland"};

then used transpose and prepend:


and theoretically:


However, transposing does not work and I really do not know where I am going wrong, or how I could produce a table of table with labels differently.

Thank you very much, apologies for the ignorant question.

  • 2
    $\begingroup$ I formatted your code, then read this question twice. I'm still not sure what you want. Transpose[{listofvariables, labelsvariablen}] might be a start as those two lists are the same length and can be transposed, but how is this supposed to relate to the list of country names? What is the actual output that you expect? $\endgroup$
    – Mr.Wizard
    Feb 22, 2017 at 9:13

1 Answer 1


Here is an attempt to answer the question. As Ms.Wizard said in a comment it is not clear what is desired outcome.

Data generation:

countryNames = CountryData["Countries", "Name"];
countryVariables = CountryData["Properties"];
commonVariables = {#, CountryData["USA", #]} & /@ 
   RandomSample[countryVariables, 30];
commonVariables = Cases[commonVariables, {_, _Quantity}][[All, 1]]
wave1Countries = RandomSample[countryNames, 4];
wave1Data = 
   Outer[{#1, CountryData[##]} &, wave1Countries, commonVariables];
wave2Countries = RandomSample[countryNames, 5];
wave2Data = 
   Outer[{#1, CountryData[##]} &, wave2Countries, commonVariables];

Make a table of tables (grid of grids, actually):

Grid[Partition[#, 2] &@
   Grid[{{Style[#1, Blue, Bold], SpanFromLeft}, 
         {Grid[#2, Alignment -> Left], Grid[#3, Alignment -> Left]}}, 
        Alignment -> Top, Dividers -> All] &, 
   {commonVariables, wave1Data, wave2Data}], 
  Dividers -> All]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.