I'm getting an error trying to compare and set weekday string values as either a "weekend" or a "weekday" using R. Any suggestions on how to approach this problem in a better way 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 get back in RStudio:
Error in day == "Sat" | "Sun" :
operations are possible only for numeric, logical or complex types