How to union two date vectors in R?
date, r, set
Solution
Just use `as.Date`
> as.Date(union(c1, c2))
[1] "2013-08-29" "2013-08-30" "2013-08-31"
Try this:
> as.Date(c(15946, 15947, 15948), origin = "1970-01-01")
[1] "2013-08-29" "2013-08-30" "2013-08-31"
Problem
I have two (considerably long) date vectors, e.g. ``` > c1 <- c( as.Date( "2013-08-29" ), as.Date( "2013-08-30" ) ) > c2 <- c( as.Date( "2013-08-30" ), as.Date( "2013-08-31" ) ) ``` and I am looking for some operation like ``` > union( c1, c2 ) [1] "2013-08-29" "2013-08-30" "2013-08-31" ``` The standard union operation in R returns ``` [1] 15946 15947 15948 ``` Does anybody know a (short/elegant) solution to this?