[R] Dates in Common

Whit Armstrong armstrong.whit at gmail.com
Fri Jan 23 15:30:33 CET 2009


you want:
ans <- intersect(data1,data2)
class(ans) <- c("POSIXt","POSIXct")

I personally think intersect should preserve the class of the object
(if both args have the same class), but I think r-core has a different
opinion.

-Whit


On Fri, Jan 23, 2009 at 9:02 AM, Tom La Bone <booboo at gforcecable.com> wrote:
>
> I have two collections of dates and I want to figure out what dates they have
> in common. This is not giving me what I want (I don't know what it is giving
> me). What is the best way to do this?
>
> Tom
>
>> data1
>  [1] "1948-02-24 EST" "1949-04-12 EST" "1950-05-29 EDT" "1951-05-21 EDT"
>  [5] "1951-12-20 EST" "1953-01-22 EST" "1955-02-28 EST" "1956-03-08 EST"
>  [9] "1957-03-22 EST" "1958-02-07 EST"
>> data2
>  [1] "1948-02-24 EST" "1949-04-12 EST" "1950-05-29 EDT" "1951-05-21 EDT"
>  [5] "1951-12-20 EST" "1953-01-22 EST" "1955-02-28 EST" "1956-03-08 EST"
>  [9] "1957-03-22 EST" "1958-02-07 EST"
>> intersect(data1,data2)
>  [1] -689626800 -653943600 -618350400 -587505600 -569098800 -534625200
>  [7] -468356400 -436042800 -403297200 -375476400
> --
> View this message in context: http://www.nabble.com/Dates-in-Common-tp21624909p21624909.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list