I get an error trying to compare and set the values โโof the day of the week string as "weekend" or "day of the week" using R. Any suggestions on how best to approach this problem would be great.
x <- c("Mon","Tue","Wed","Thu","Fri","Sat","Sun") setDay <- function(day){ if(day == "Sat" | "Sun"){ return("Weekend") } else { return("Weekday") } } sapply(x, setDay)
This is the error I return to RStudio:
Error in day == "Sat" | "Sun" : operations are possible only for numeric, logical or complex types
source share