[R] Help with assigning a value based on existing numbers

sjaffe sjaffe at riskspan.com
Fri Mar 26 15:53:05 CET 2010


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"

-- 
View this message in context: http://n4.nabble.com/Help-with-assigning-a-value-based-on-existing-numbers-tp1692200p1692321.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list