Displaying 2 results from an estimated 2 matches for "nonwblreljob".
2017 Aug 10
3
Creating New Variable Using Ifelse
...c(0,1), labels = c("No","Yes"))
elsq2wbl$PSWBL <- factor(elsq2wbl$PSWBL, levels = c(0,1), labels = c("No","Yes"))
##Trying to create a new variable to indicate if the student had a job
#related to the college studies that was NOT a WBL experience
elsq2wbl$NONWBLRELJOB <- ifelse(elsq2wbl$PSWBL=="No" & elsq2wbl$EVERRELJOB=="Yes",1,0)
#Cross tab to check counts of two variables that new variable is based upon
xtabs(~PSWBL+EVERRELJOB,subset(elsq2wbl,BYSCTRL==1&G10COHRT==1),addNA=TRUE)
#Checking count of newly created variable
Q2sub &...
2017 Aug 10
0
Creating New Variable Using Ifelse
...uot;,"Yes"))
> elsq2wbl$PSWBL <- factor(elsq2wbl$PSWBL, levels = c(0,1), labels =
> c("No","Yes"))
>
> ##Trying to create a new variable to indicate if the student had a job
> #related to the college studies that was NOT a WBL experience
> elsq2wbl$NONWBLRELJOB <- ifelse(elsq2wbl$PSWBL=="No" &
> elsq2wbl$EVERRELJOB=="Yes",1,0)
You can use simple logical functions to get desired result
First sample data
> a <- sample(c("Y", "N"), 30, replace=TRUE)
> b <- sample(c("Y", "N"),...