Need to write large if statement


I am trying to write a large if statement in R studio. I am trying to just get the basic statement to work, but i'm having trouble.

Currently, i have:

md$"Type" <- if(md$"Numbers" == 52123551110622) {"2X12_355_11X10"} else{NULL}

Which returns the error: Warning in if (md$"Numbers" == 52123551110622) { : the condition has length > 1 and only the first element will be used

I have an entire column of numbers in the "Numbers" column that i will need to add to the if statement. So if the numbers match a certain number pattern, it will return the number formatting to the "type" column.

if() is used for evaluating single conditions and is not vectorised. There is a vectorised version which evaluates each element of a vector in turn, it is ifelse()
A good resource to learn R, and one that i used myself is 'swirl'

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.