-
Notifications
You must be signed in to change notification settings - Fork 30
Description
While passing an R vector of timestamps to the timeseries_client.R parseIso8601 function, I got this message:
Warning message:
In if (substr(isoText, len - 2, len - 2) == ":") { :
the condition has length > 1 and only the first element will be used
I modified the relevant portion of the function code to use an ifelse statement and no longer get the warning message:
ifelse(substr(isoText, len - 2, len - 2) == ":",
isoText <- paste0(substr(isoText, 1, len - 3), substr(isoText, len - 1, len)),
ifelse(substr(isoText, len, len) == "Z",
isoText <- paste0(substr(isoText, 1, len - 1), "+0000")
)
)
Alex's email included an easy way to demonstrate that the parseIso8601 function only works on strings rather than vectors:
For example, this line of code will produce the warning:
ii=c("00:00","00:01"); if(substr(ii, 5- 2, 5 - 2) == ":") { print("hey") }else{print("no")}
but if use just a string for ii, no error.
ii="00:00"; if(substr(ii, 5- 2, 5 - 2) == ":") { print("hey") }else{print("no")}
The ifelse construct in R works with vectors.