[R] Split data

Phil Spector spector at stat.berkeley.edu
Thu Sep 30 00:14:10 CEST 2010


Ali -
    A reproducible example would be very helpful, but I'll
try to guess what you mean.

> mydat = data.frame(year=rep(2008:2010,each=5),var=1:15)
> sdat = split(mydat$var,mydat$year)
> do.call(cbind,sdat)
      2008 2009 2010
[1,]    1    6   11
[2,]    2    7   12
[3,]    3    8   13
[4,]    4    9   14
[5,]    5   10   15
 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu




On Wed, 29 Sep 2010, Ali S wrote:

> I used split() to split a variable by 3 years, but am wondering how to call up that split data and use it in further analyses. Can I make separate columns for the 3 resulting year groups?
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list