Flattening nested lists: use vec(l)
DataFrames: Set data up either column or row centric as desired. If row centric, add a new row with,
using DataFrames
DF = DataFrame
In [106]:
a = DF(a = [1,2,3], b = [4,5,6])
# add a new row at the end. `;` is shorthand for vcat, I think.
a = [a; DF(a = [7], b = [8])]
Out[106]:
a b
1 1 4
2 2 5
3 3 6
4 7 8
Column-centric to me, often feels better:
In [109]:
a = DF(a = [1,2,3], b = [4,5,6])
a[:newColumn] = [7,8,9]
Out[109]:
a b newColumn
1 1 4 7
2 2 5 8
3 3 6 9
but then plotting with GadGly is much neater if we have three columns with all the data:
c1 -> x axis; c2 -> y axis; c3 = color of plot.
At plot time, rearrange so that the column title becomes the color entry:
Out[109]:
a b newColumn
1 1 4 7
2 2 5 8
3 3 6 9
In [110]: b = stack(a, [:a, :b])
Out[110]:
variable value newColumn
1 a 1 7
2 a 2 8
3 a 3 9
4 b 4 7
5 b 5 8
6 b 6 9
No comments:
Post a Comment