Re: [R] Combining Rows from One Data Frame, Outputting into Another

2014-08-01 Thread arun
You could use:     library(dplyr)     library(tidyr)   x.df %>% group_by(Year, Group, Eye_Color) %>% summarize(n=n()) %>% spread(Eye_Color,n, fill=0) Source: local data frame [6 x 5]   Year Group blue brown green 1 2000 1    2 1 0 2 2000 2    0 0 2 3 2001 1    1  

Re: [R] Combining Rows from One Data Frame, Outputting into Another

2014-08-01 Thread Jeff Newmiller
library(reshape2) ?dcast Nice example. So nice that it looks like it could be homework... thus the pointer to docs rather than a full solution. Please read the Posting Guide, and note that HTML email format is not necessarily a what-you-see-is-what-we-see format so you should post in plain text

[R] Combining Rows from One Data Frame, Outputting into Another

2014-08-01 Thread Kathy Haapala
If I have a dataframe x.df as follows: > x.df <- data.frame(Year = c(2000, 2000, 2000, 2000, 2000, 2001, 2001, 2001, 2001, 2002), Group = c(1, 1, 1, 2, 2, 1, 2, 2, 3, 1), Eye_Color = c("blue", "blue", "brown", "green", "green", "blue", "brown", "blue", "blue", "blue")) > x.df Year Group Eye_Col

Re: [R] combining rows

2011-09-04 Thread David Winsemius
On Sep 4, 2011, at 8:35 PM, R. Michael Weylandt wrote: Kang Tu is right and you will certainly need to learn the techniques being suggesting to do more advanced data analysis, but it sounds like for your immediate problem the following might work: # Suppose df is your data frame This tak

Re: [R] combining rows

2011-09-04 Thread R. Michael Weylandt
Kang Tu is right and you will certainly need to learn the techniques being suggesting to do more advanced data analysis, but it sounds like for your immediate problem the following might work: # Suppose df is your data frame rowSums(df[,4:27]) This takes a sub-data-frame consisting only of column

Re: [R] combining rows

2011-09-04 Thread Kang Tu
Would you mind show us a simple example of your data? It is hard to understand your request directly from your text. If you just want to combine the data, you can try cbind() function directly, or you can use subset() function to get a subset of your data.frame. If you want to selectively aggrega

[R] combining rows

2011-09-04 Thread joonsum
First time using R and have so many basic questions. The problem that I have confronted is combining rows. I have a data frame that contains daily rain falls from 60 to 80. There are 27 columns which are Year,month, day, and record in hours. I am trying to combine the 4th column to the 27th to g