Apologies for the novice question, but this is likely beyond my google searching range.. I am trying to create a table from the summaries of a file. The 2 column data table looks like; Harry 335/335 Harry 124/506 Harry 124/506 Dick 133 Tom 335/335 Tom 335/335 with 1000 unique values in col 1, 300 unique in col 2. The 'summary' doesn't seem to handle this many values well. I would like to summarise this data in a table that reads the number of occurences of the values of col 2 for each unique name in col 1... Along the lines... 335/335 124/506 133 Tom 2 0 0 Dick 0 0 1 Harry 1 2 0 I hope I can trouble someone for their expert advice on what is likely a trivial matter... Many thanks. -- View this message in context: http://www.nabble.com/Table-of-Summaries-tp23842984p23842984.html Sent from the R help mailing list archive at Nabble.com.
Hi there, It is not so many ellegant, but can works. df<-read.table(stdin(), head=T, sep=",") Name,Fraction Harry,335/335 Harry,124/506 Harry,124/506 Dick,133 Tom,335/335 Tom,335/335 df.freq<-data.frame(table(df)) df.freq df.freq.wide<-reshape(df.freq, v.names="Freq", idvar="Name", timevar="Fraction", direction="wide") df.freq.wide cheers milton brazil=toronto On Tue, Jun 2, 2009 at 7:41 PM, sedm1000 <gdoran@mit.edu> wrote:> > Apologies for the novice question, but this is likely beyond my google > searching range.. > > I am trying to create a table from the summaries of a file. The 2 column > data table looks like; > > Harry 335/335 > Harry 124/506 > Harry 124/506 > Dick 133 > Tom 335/335 > Tom 335/335 > > with 1000 unique values in col 1, 300 unique in col 2. The 'summary' > doesn't seem to handle this many values well. > > I would like to summarise this data in a table that reads the number of > occurences of the values of col 2 for each unique name in col 1... > > Along the lines... > > 335/335 124/506 133 > Tom 2 0 0 > Dick 0 0 1 > Harry 1 2 0 > > I hope I can trouble someone for their expert advice on what is likely a > trivial matter... > Many thanks. > -- > View this message in context: > http://www.nabble.com/Table-of-Summaries-tp23842984p23842984.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Thanks for all your help guys - turns out it was a very simple request, table1<-table(DF$COLUMN1,DF$COLUMN2) did the trick. I've much to learn... Cheers. sedm1000 wrote:> > Apologies for the novice question, but this is likely beyond my google > searching range.. > > I am trying to create a table from the summaries of a file. The 2 column > data table looks like; > > Harry 335/335 > Harry 124/506 > Harry 124/506 > Dick 133 > Tom 335/335 > Tom 335/335 > > with 1000 unique values in col 1, 300 unique in col 2. The 'summary' > doesn't seem to handle this many values well. > > I would like to summarise this data in a table that reads the number of > occurences of the values of col 2 for each unique name in col 1... > > Along the lines... > > 335/335 124/506 133 > Tom 2 0 0 > Dick 0 0 1 > Harry 1 2 0 > > I hope I can trouble someone for their expert advice on what is likely a > trivial matter... > Many thanks. >-- View this message in context: http://www.nabble.com/Table-of-Summaries-tp23842984p23851705.html Sent from the R help mailing list archive at Nabble.com.