문제

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