Question

I get the following error message:

Error in if (sum(c(new$hour, new$min, new$sec))) { : 
  argument is not interpretable as logical

when I execute the following code:

keep$EstimateDate <- as.Date(keep$date + keep$days,"%Y-%m-%d")
keep$EstimateDateWeekStart <- floor_date(keep$EstimateDate,"week") #+1

The keep$EstimateDate is a column in a data.table with properly formatted dates.

The floor_date() is a function in the lubridate package.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top