Skip to content
Prev 383203 / 398502 Next

how to create a new column with conditions

Now that you have been shown how to do this, post your (non-working) code next time. And configure your email program to send plain text so we will see what you saw.

a$PHENO <- ifelse( a$CURRELIG==1
                 & a$RTNPTHY==1
                 , 1
                 ,  ifelse( a$PLASER==2
                          , 2
                          , -9 ) )

or

a$PHENO <- with( a
               , ifelse( CURRELIG==1
                       & RTNPTHY==1
                       , 1
                       , ifelse( PLASER==2
                               , 2
                               , -9 ) ) )
On April 8, 2020 1:17:38 PM PDT, Ana Marija <sokovic.anamarija at gmail.com> wrote: