[R] how to create a new column from two columns with conditions
Ana Marija
@okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Wed Apr 29 21:19:18 CEST 2020
Hello,
I have a data frame like this:
> head(b)
FID IID FLASER PLASER
1: fam1000 G1000 1 1
2: fam1001 G1001 1 1
3: fam1003 G1003 1 2
4: fam1005 G1005 1 1
5: fam1009 G1009 2 1
6: fam1052 G1052 1 1
...
My conditions for creating a new column PHENO would be this:
if FLASER or PLASER =2 then PHENO=2
otherwise PHENO=1
so result would look like this:
> head(b)
FID IID FLASER PLASER PHENO
1: fam1000 G1000 1 1 1
2: fam1001 G1001 1 1 1
3: fam1003 G1003 1 2 2
4: fam1005 G1005 1 1 1
5: fam1009 G1009 2 1 2
6: fam1052 G1052 1 1 1
...
Thanks
Ana
...
More information about the R-help
mailing list