The only scenario I can think of where you get an error in if
but don't in sum
, is when you have an NA
in your sum. With that in mind, this is most likely what's happening:
floor_date(as.Date(NA), "week")
#Error in if (sum(c(new$hour, new$min, new$sec))) { :
# argument is not interpretable as logical
In other words, check that you don't have any NA
's.