Kapo C. answered 02/26/17
Tutor
4.9
(18)
Experienced scientist, passionnate about teaching
In R a quick and dirty approach would be:
weekdays<-function(x) {
if (x > 6 | x <0) stop (" invalid entry, number should be an integer between 0 and 6")
days<-c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
return(days[x+1])
}
So calling weekdays(0) will produce "Sunday"