Skip to content
Prev 215100 / 398500 Next

Help with assigning a value based on existing numbers

An expression like "v >= 52", where v is a vector, will produce a vector
resulting from comparing each entry -- that is why you see the message.

What you want to do is logical subscripting.  For example

names <- character( nrow( curveData ) )

names[ curvedata$Date.difference <= 29  ] = "< 1 month"

etc.

Also, to test for a NULL value do not compare to the string "NULL", use the
test operator is.null:

names[ is.null( curvedata$Date.difference ) ] = "missing"