Compare two dates in R Compare two dates in R r r

Compare two dates in R


The following solution solved my problem:Instead of using the Date data type, I tried to use the POSIXct data type.Here is the example code for reading the tab-separated textfile after which the subsetting worked in all steps of my for loop:

data = read.table("data.txt", header = TRUE, sep = "\t", dec = ".",     colClasses =c("numeric","numeric","character","POSIXct","numeric","numeric"));startDate = as.POSIXct("2012-07-01");endDate = as.POSIXct("2012-07-20");all_dates = seq(startDate, endDate, 86400); #86400 is num of seconds in a day#the following code I'm trying to run inside a loop...for (j in 1:length(all_dates)) {    filterdate = all_dates[j];    my_subset = data[data$DateTimeUTC == filterdate,]    #now I want do do some processing on my_subset...}