0

So i tried an if else statement but failed...

(I am working with string columns, in R)

hostpairs["hostspecificity"] <- NA

If (hostpairs$hostgenus2 == NA){
  hostpairs$hostspecificity == 0
} else if(hostpairs$hostgenus1 == hostpairs$hostgenus2){
  hostpairs$hostspecificity == 1
} else {
  hostpairs$hostspecificity == 2
}

Error in if (hostpairs$hostgenus2 == NA) { :
missing value where TRUE/FALSE needed
In addition: Warning message:
In if (hostpairs$hostgenus2 == NA) { : the condition has length > 1 and only the first element will be used

I am pretty sure there is a pretty dumb mistake somewhere in there...

ps. Also if there is a function that checks two string column row by row and comes up with TRUE if they are equal (case insensitive, John = JOHN) or FALSE if they are not equal (John != Mary) That would be very helpful!

Konrad Rudolph
  • 506,650
  • 124
  • 909
  • 1,183
Kostas Daglis
  • 29
  • 1
  • 5

0 Answers0