Hi ! I would like to know how is it possible to use variables in subsets of DataFrames ? I would like to use a syntax like df[:,:titles[1]] and df[:,:titles[1:3]]
Thanks for your help ! julia> using DataFrames julia> df = readtable("test.csv", separator = '\t') 8x5 DataFrame | Row | title1 | title2 | title3 | title4 | title5 | |-----|--------|--------|--------|--------|--------| | 1 | 10 | 20 | 30 | 40 | 50 | | 2 | 11 | 21 | 31 | 41 | 51 | | 3 | 12 | 22 | 32 | 42 | 52 | | 4 | 13 | 23 | 33 | 43 | 53 | | 5 | 14 | 24 | 34 | 44 | 54 | | 6 | 15 | 25 | 35 | 45 | 55 | | 7 | 16 | 26 | 36 | 46 | 56 | | 8 | 17 | 27 | 37 | 47 | 57 | julia> titles = readdlm("titles.csv") 3x1 Array{Any,2}: "title3" "title1" "title5" julia> df[:,:title2] 8-element DataArray{Int64,1}: 20 21 22 23 24 25 26 27 julia> titles[1] "title3" julia> df[:,:titles[1]] ERROR: `getindex` has no method matching getindex(::Symbol, ::Int64) julia> df[:,:titles[1:3]] ERROR: `getindex` has no method matching getindex(::Symbol, ::UnitRange{ Int64})
title1 title2 title3 title4 title5 10 20 30 40 50 11 21 31 41 51 12 22 32 42 52 13 23 33 43 53 14 24 34 44 54 15 25 35 45 55 16 26 36 46 56 17 27 37 47 57
title3 title1 title5