mercredi 19 décembre 2018

Add data to column based on values from other columns

I have a dataset, which looks like this

Col1  Col2  Col3
A       B    NA
AA      C    NA
D       CC   NA
E       F    NA

I would like to add data to col3 based on condition. If col1 and col2 only have one letter each, write "SNP". If col1 has more than one letter, write "DEL" and if col2 has more than one letter, write "INS"

Final product would be:

Col1  Col2  Col3
A       B    SNP
AA      C    DEL
D       CC   INS
E       F    SNP

Anyone would know how to do this in R?

Thank you!

Aucun commentaire:

Enregistrer un commentaire