Displaying 2 results from an estimated 2 matches for "q2sub".
2017 Aug 10
3
Creating New Variable Using Ifelse
...LRELJOB <- 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 <- subset(elsq2wbl,BYSCTRL==1&G10COHRT==1)
library(plyr)
count(Q2sub,'NONWBLRELJOB')
#The new variable has the correct count of "1", but 88 cases too many for "0"
#The cross tab shows 20 and 68 NA cases that are being incorrectly counted as "0" in the n...
2017 Aug 10
0
Creating New Variable Using Ifelse
...0 0 0 1 0 0 0 0 0 0
[26] 0 0 0 0 1
Cheers
Petr
>
> #Cross tab to check counts of two variables that new variable is based upon
> xtabs(~PSWBL+EVERRELJOB,subset(elsq2wbl,BYSCTRL==1&G10COHRT==1),add
> NA=TRUE)
>
> #Checking count of newly created variable
> Q2sub <- subset(elsq2wbl,BYSCTRL==1&G10COHRT==1)
> library(plyr)
> count(Q2sub,'NONWBLRELJOB')
>
> #The new variable has the correct count of "1", but 88 cases too many for "0"
> #The cross tab shows 20 and 68 NA cases that are being incorrectly counted a...