资源描述:
《chronological objects for data analysis》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、daysReturnVariousPeriodsfromaChronorDatesObjectdaysdays(x)weekdays(x,abb=T)months(x,abb=T)quarters(x,abb=T)years(x)ARGUMENTSx:adatesobject.abb:shouldabbreviatednamesbereturned?DefaultisTRUE.VALUEanorderedfactorcorrespondingtodays,weekdays,months,quarters,oryearsofxfortherespectivefunction.SEEALSOi
2、s.weekend,is.holidayEXAMPLE#produceboxplotsbydayoftheweekandmonthsplot(weekdays(dts),x)plot(months(dts),y)seq.datesGenerateChronorDatesSequencesseq.datesseq.dates(from,to,by="days",length.)ARGUMENTSfrom:startingdate;itcanbeachronordatesobjet,acharacterstring,e.g.,"05/23/91",oraJuliandate.to:ending
3、date,likefrom.by:eitheranumericvalueoroneofthevalidstrings"days","weeks","months",or"years".length.:optionalnumberofelementsinthesequence.VALUEasequencewithvalues(from,from+by,from+2*by,...,to)ofclassclass(from)andoriginorigin(from).Notethatfrommustbelessthanorequaltotheargumentto.SEEALSOcut.dates
4、EXAMPLE>seq.dates("01/01/92","12/31/92",by="months")[1]01/01/9202/01/9203/01/9204/01/9205/01/9206/01/92[7]07/01/9208/01/9209/01/9210/01/9211/01/9212/01/92>end.of.the.month<-seq.dates("02/29/92",by="month",length=15)>end.of.the.month[1]02/29/9203/31/9204/30/9205/31/9206/30/9207/31/92[7]08/31/9209/3
5、0/9210/31/9211/30/9212/31/9201/31/93[13]02/28/9303/31/9304/30/9314julianConvertbetweenJulianandCalendarDatesjulianjulian(m,d,y,origin=c(month=1,day=1,year=1970))month.day.year(jul,origin=c(month=1,day=1,year=1970))leap.year(y)day.of.week(month,day,year)ARGUMENTSm:vectorofmonthnumbers.d:vectorofday
6、numbers.y:vectorofyears.jul:vectorofJulianDates,i.e.,numberofdayssinceorigin.origin:vectorspecifyingtheoriginasmonth,day,andyear.Thedefaultisc(month=1,day=1,year=1970).VALUEAvectorofJuliandates(numberofdayssinceorigin)whenjulian()iscalled,oralistwithmembersmonth,day,yearcorrespondingtotheinputJuli
7、andatesifmonth.day.year()iscalled.leap.year()returnsalogicalvectorindicatingwhetherthecorrespondingyearisaleapyear.day.of.week()returnsanumberbetween0and6tospecifydayoftheweek{0referstoSunday.Thesefunctionswereta