Nothing
# invyrfraction.R
# convert fraction of the year into a date (day and month)
# month on a scale of [1,13)
# type = monthly/daily
# Oct 2011
invyrfraction<-function(frac,type='daily',text=TRUE){
n<-length(frac)
if(sum(frac<0)+sum(frac>1)>0){stop('Fraction must be between 0 and 1')}
if (type=='daily'){
yrlength<-365.25;
day<-(frac*yrlength)+1;
day=day-(365*as.numeric(day>365)); # avoid values > 365
day=pmax(day,1); # avoid values < 1
date<-strptime(day,'%j');
day<-as.numeric(format(date,'%d')); # Day of the month as decimal number (0131)
month<-format(date,'%B'); # Month name
if (text==TRUE){daym<-paste('Month =',month,', day =',day)}
if (text==FALSE){
monthnum<-as.numeric(format(date,'%m')); # Month number
mnthlength<-c(31,28.25,31,30,31,30,31,31,30,31,30,31)
daym<-monthnum+((day-1)/mnthlength[monthnum])
} #
}
if (type=='monthly'){
month<-(frac*12)+1;
if (text==TRUE){daym<-paste('Month =',round(month,1))}
if (text==FALSE){daym<-month}
}
return(daym)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.