[R] Generating variable from 2 others in dataframe

2010-03-01 Thread o.mann...@auckland.ac.nz
Suppose I have the following dataframe called test: test-data.frame(year=rep(1990:2003,5),id=gl(5,length(1990:2003)),eif=as.vector(sapply(1:5,function(z){a-rep(0,length(1990:2003));a[sample(1:length(1990:2003),sample(1:2,1))]-1;a}))) year id eif 1990 1 0 1991 1 0 1992 1 0 2000 1 1

Re: [R] Generating variable from 2 others in dataframe

2010-03-01 Thread Bert Gunter
: Monday, March 01, 2010 2:03 PM To: 'r-help@r-project.org' Subject: [R] Generating variable from 2 others in dataframe Suppose I have the following dataframe called test: test-data.frame(year=rep(1990:2003,5),id=gl(5,length(1990:2003)),eif=as.vec tor(sapply(1:5,function(z){a-rep(0,length(1990:2003