I am trying to create a function that will take an input of character strings "mm/did/yyyy" and return an output vector in numeric form the month, day and year. I essentially want to combine this new function with the weekday() function created below to ultimately return the day of the week the input character string corresponds with.
weekday<-function(q,r,s)
{ (if(q>= 3)
m<-(q-2)
else
m<-(q+10))
k<-r
c<-floor(s/100)
(if(q>=3)
y<-s%%100
else
y<-(s%%100)-1)
f<-(floor((2.6*m)-0.2)+k+y+floor(y/4)+floor(c/4)-(2*c))%%7
if(f==0){return("Sunday")}
else
if(f==1){return("Monday")}
else
if(f==2){return("Tuesday")}
else
if(f==3){return("Wednesday")}
else
if(f==4){return("Thursday")}
else
if(f==5){return("Friday")}
else
if(f==6){return("Saturday")}}
I tried using something along the lines of type.convert but this isn't producing the desired output. Any help would be great thanks!
dateconvert<-function("q/r/s")
{
type.convert(dateconvert(), na.strings = )
weekday(convertedanswer)
Return (weekday)
}
?weekdays.