Would the by function help here? E.g. something like
julia> df = DataFrame(ct = vcat(fill("A", 3), fill("B", 5)), x = randn(8))
8×2 DataFrames.DataFrame
│ Row │ ct │ x │
├─────┼─────┼───────────┤
│ 1 │ "A" │ -1.17715 │
│ 2 │ "A" │ 0.781145 │
│ 3 │ "A" │ 0.74948 │
│ 4 │ "B" │ -1.88212 │
│ 5 │ "B" │ 1.30658 │
│ 6 │ "B" │ -0.578074 │
│ 7 │ "B" │ -0.710504 │
│ 8 │ "B" │ -1.98858 │
julia> by(df, :ct, d -> mean(d[:x]))
2×2 DataFrames.DataFrame
│ Row │ ct │ x1 │
├─────┼─────┼───────────┤
│ 1 │ "A" │ 0.117825 │
│ 2 │ "B" │ -0.770539 │
On Sun, Sep 4, 2016 at 3:49 PM, Reuben <[email protected]> wrote:
> Seems like this should be easy, probably is, but I cannot figure out how
> to get it to work with the melt / stack functions. The reason I want to is,
> I'm finding that with the data I have, I search for a the row where the
> string in column 1 == myparameter, then I get the values for columns 2-6,
> clumsily extract them into an array (because a dataframe row is not a
> dataArray), then apply the mean function to this array. It would be a lot
> simpler to have column names that were based on my parameter values. Then i
> could say "mean(df[:parameter][2:6])" and be done.
>
> I suspect I am missing out on how to use dataframes to make this easy; can
> someone point me in the right direction?
>
> -Reuben
>
> --
> You received this message because you are subscribed to the Google Groups
> "julia-stats" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.