1
$\begingroup$

I'm trying to construct and display properly DataSet. Everything works fine, except the index column('Year'). I'm trying different variants:

Example 1:

data := Dataset[{<|"Year"-> Range[t],"x1"-> Column[Array[S[#]&,t]]
                ,"x2" -> Column[Array[R[#]&,t]], 
                "x3" -> Column[Array[Y[#]&,t]], 
                "x4"-> Column[Array[S[#]/R[#]&,t]]|>}]
    data

Output: enter image description here

Example 2:

data := Dataset[{<|"Year"-> Column[Range[t]],"x1"-> Column[Array[S[#]&,t]]
                ,"x2" -> Column[Array[R[#]&,t]], 
                "x3" -> Column[Array[Y[#]&,t]], 
                "x4"-> Column[Array[S[#]/R[#]&,t]]|>}]

In this example, all columns display horizontally.

So, what is the right approach to solve this problem?

$\endgroup$
1
$\begingroup$
t = 10;
keys = {"Year","x1","x2","x3"};
years = Range[t];
x1values = RandomReal[10, t]; (* your Array[S, t] *)
x2values = RandomInteger[1000, t]; (* your Array[R, t] *)
x3values = RandomWord["Noun", t];

data = Dataset[AssociationThread[keys -> #]&/@
    Transpose[{years, x1values, x2values, x3values}]]

enter image description here

ds = Dataset[AssociationThread[{"Year", "x1", "x2", "x3", "x4"} -> #] & /@ 
  Transpose[{Range[10], Array[S, t], Array[R, t], Array[Y, t], Array[S[#]/R[#] &, t]}]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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