This question already has an answer here:
- Vectorized IF statement in R? 6 answers
Sorry for the really basic question, I have looked everywhere but cannot find an answer. I have a data frame (d.f) looking like this:
A count A variant B count B variant
3---------G-----------2----------T
9---------A-----------2----------T
3---------A-----------8----------C
I would like to create a fifth column, and have written this code for it
if(d.f$A_count>d.f$B_count)
d.f$Fifth <- d.f$A_variant else
d.f$Fifth <- d.f$B_variant
My fifth column should have G, A, C
How can I make the if condition work for my data frame, basically making a loop for every row?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire