Good evening everyone! I want to do a comparison between dates in R. I have 2 datasets, maint.csv and failures.csv:
> str(maint)
'data.frame': 3286 obs. of 3 variables:
$ datetime : POSIXct, format: "2014-06-01 06:00:00" "2014-07-16 06:00:00" "2014-07-31 06:00:00" ...
$ machineID: int 1 1 1 1 1 1 1 1 1 1 ...
$ comp : Factor w/ 4 levels "comp1","comp2",..: 2 4 3 1 4 1 3 1 4 3 ...
and
> str(failures)
'data.frame': 761 obs. of 3 variables:
$ datetime : POSIXct, format: "2015-01-05 06:00:00" "2015-03-06 06:00:00" "2015-04-20 06:00:00" ...
$ machineID: int 1 1 1 1 1 1 1 2 2 2 ...
$ failure : Factor w/ 4 levels "comp1","comp2",..: 4 1 2 4 4 2 4 1 2 2 ...
As you can see both the datetime are in POSIX format. Now, the 761 rows of failures.csv are like a subset of the 3286 row of maint.csv in the sense that more or less all the observations of failures are taken from the maint file, but there are some rows that are not present in the maint.csv I want to build a for loop that prints only the rows that are present in failures but not in maint How can I do? I've never used for, if-else in R, and especially i don't know how to compare dates. Thank you.