[julia-users] Re: Grouping - Dataframes

2015-02-22 Thread Philip Sivyer
Hi
I get 
:Col1 anonymous function)) when I try *(df,:Col1,x-sum(x[:Col2]))*
Any ideas.
Will take a look at the link in a minute
Regards


On Sunday, February 22, 2015 at 8:06:59 PM UTC, Philip Sivyer wrote:

 Hi
 Is it possible to summarize data in a data frame eg

 Col1  Col2
 A 2
 A 2.5
 B 7
 B 2

 I would like sum Col2 grouping by Col1 - output would be
 A , 4.5
 B,9


 Regards




[julia-users] Re: Grouping - Dataframes

2015-02-22 Thread Philip Sivyer
Hi
Looked at the link and wondering how I can convert my txt file.
The code below works nicely - how can I get my test.txt file with Col1  
Col2 data to be like iris?
What do I need to change in the below code?

using DataFrames
using RDatasets
iris = dataset(datasets, iris)
by(iris, :Species, size)
by(iris, :Species, df - mean(df[:PetalLength]))
by(iris, :Species, df - DataFrame(N = size(df, 1)))

Regards

On Sunday, February 22, 2015 at 8:06:59 PM UTC, Philip Sivyer wrote:

 Hi
 Is it possible to summarize data in a data frame eg

 Col1  Col2
 A 2
 A 2.5
 B 7
 B 2

 I would like sum Col2 grouping by Col1 - output would be
 A , 4.5
 B,9


 Regards




[julia-users] Re: Grouping - Dataframes

2015-02-22 Thread Jeff Waller


On Sunday, February 22, 2015 at 4:07:48 PM UTC-5, Philip Sivyer wrote:

 Hi
 I get 
 :Col1 anonymous function)) when I try *(df,:Col1,x-sum(x[:Col2]))*
 Any ideas.
 Will take a look at the link in a minute
 Regards


you forgot the by 


[julia-users] Re: Grouping - Dataframes

2015-02-22 Thread Jeff Waller
if the DataFrame if represented by the variable df, how about


*by(df,:Col1,x-sum(x[:Col2]))*




[julia-users] Re: Grouping - Dataframes

2015-02-22 Thread pgs
Hi
This now works - by *(df,:Col1,x-sum(x[:Col2])) - it was my fault as I 
left out a  in one of the headers in my txt file.*
*Thanks*


On Sunday, February 22, 2015 at 8:06:59 PM UTC, pgs wrote:

 Hi
 Is it possible to summarize data in a data frame eg

 Col1  Col2
 A 2
 A 2.5
 B 7
 B 2

 I would like sum Col2 grouping by Col1 - output would be
 A , 4.5
 B,9


 Regards