hi Paulie, Further to Sarahâs email, this will give the same sex indicator (both 0 or both 1 then samesex scores 1):
samesex<-ifelse(sex==sex1,1,0) from what you have described this will give you the desired result hope that helps, Rob Robert M Griffin Department of Evolutionary Biology Evolutionary Biology Centre Uppsala University Norbyvägen 18D SE-752 36 Uppsala Sweden http://www.ebc.uu.se/Research/IEG/evbiol/people/pages/Griffin_Rob/ -----Original Message----- From: Sarah Goslee Sent: Thursday, November 10, 2011 2:41 PM To: David . Cc: r-help@r-project.org Subject: Re: [R] Creating dummys in R Without having any actual idea what you mean (sample data!), this might work: sex <- c(1,0,1,0) sex1 <- c(1,1,0,0) samesex <- ifelse(sex == 1 & sex1 == 1, 1, 0) Note that this does NOT return 1 if both initial variables are 0, so it isn't really a samesex indicator, but it is my best guess as to what you might want. Sarah On Thu, Nov 10, 2011 at 5:13 AM, David . <loove...@hotmail.com> wrote: > > Dear R-project! > > How do i create 1 dummy from 2 already existing dummys. To be more precise, I > want to create a dummy from a dummy called "sex" and another called "sex1" > when both thoose dummys are 1 I want my created dummy "samesex" to take 1. > > Thanks for the help! > > Paulie > -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ 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. [[alternative HTML version deleted]]
______________________________________________ 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.