[R] how to create a new column with conditions

Ana Marija @okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Wed Apr 8 22:17:38 CEST 2020


Hi,

I have a data frame like this:

> head(a)
            FID LASER2 CURRELIG PLASER RTNPTHY
1 fam1000_G1000      1        1      1       1
2 fam1001_G1001      1        1      1       1
3 fam1003_G1003      2        1      2       2
4 fam1005_G1005      1        1      1       2
5 fam1009_G1009      1        1      1       2
6 fam1052_G1052      1        1      1       2
...

I would like to create a new column called PHENO which would satisfy these
conditions:

if CURRELIG=1 and RTNPTHY=1 than PHENO=1
if PLASER=2 than PHENO=2
otherwise is -9

Thanks
Ana

	[[alternative HTML version deleted]]



More information about the R-help mailing list