[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
1994  1   0
1995  1   0
2001  1   0
1997  1   1


I want to create a new variable in this dataframe called "hhtype" according to 
the logic:
If eif==1, hhtype = 1
Else if year < 2000, hhtype = 2
Else hhtype = 3

The result would be

year id eif hhtype
1990  1   0 2
1991  1   0 2
1992  1   0 2
2000  1   1 1
1994  1   0 2
1995  1   0 2
2001  1   0 3
1997  1   1 1

I think I can do this with some combination of apply and ifelse, but so far 
have not succeeded in putting it all together. Any help would be very much 
appreciated!

Thankyou,
Oliver

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Where has the stats-rosuda-devel mailing list gone?

2010-05-13 Thread o.mann...@auckland.ac.nz
I require some assistance with JGR, but following the mailing list link from 
http://jgr.markushelbig.org/FAQ.html leads me to 
http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel which 
responds with

No such list stats-rosuda-devel

I was previously subscribed to this mailing list and want to resubscribe, but 
where has it gone?

Many thanks,


Oliver Mannion
Programmer
COMPASS - Centre of Methods and Policy Application in the Social Sciences
www.compass.auckland.ac.nz
The University of Auckland, New Zealand

Phone +(649) 373 7999 ext 89760



__ Information from ESET NOD32 Antivirus, version of virus signature 
database 5113 (20100513) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.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
and provide commented, minimal, self-contained, reproducible code.