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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top