How do I prevent R from coercing this vector of Dates to numeric? -


when combining date vector na, r coerce whole vector numeric if na appears first. if na not appear first coerce date.

x <- sys.date() c(na, x) # [1]    na 16248 c(x, na) # [1] "2014-06-27" na 

how can make coerce date always, regardless of order nas appear? secondly, if not know type of x, how can still coerces class of vector x , not numeric?

this result of s3 method dispatch acting on first argument na , hence default method used coerces numerics. solution explicit method call, in case c.date():

x <- sys.date() xx <- c.date(c.date(na, x)) xx class(xx)  > xx [1] na           "2014-06-27" > class(xx) [1] "date" 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -