[R] convert S-Plus function to R function

Gabor Grothendieck ggrothendieck at gmail.com
Wed May 7 05:05:32 CEST 2008


R News 4/1 has an article on this dates and the last page
contains a table with many date idioms.

On Tue, May 6, 2008 at 10:00 PM, Roslina Zakaria <zroslina at yahoo.com> wrote:
> Hi R-expert,
> If I have this daily rainfall data, how do call a particular set of data?
>
> Year,Month,Day,Amount
> 1981,1,1,0
> 1981,1,2,0
> 1981,1,3,78
> 1981,1,4,22
> 1981,1,5,2
> 1981,1,6,0
> 1981,1,7,0
> 1981,1,8,0
> 1981,1,9,0
> 1981,1,10,10
> 1981,1,11,0
> 1981,1,12,108
> 1981,1,13,328
> 1981,1,14,10
> 1981,1,15,0
> 1981,1,16,6
> 1981,1,17,0
> 1981,1,18,28
> 1981,1,19,0
> 1981,1,20,0
> 1981,1,21,0
> 1981,1,22,0
> 1981,1,23,0
> 1981,1,24,0
> 1981,1,25,32
> 1981,1,26,0
> 1981,1,27,2
> 1981,1,28,0
> 1981,1,29,2
> 1981,1,30,0
> 1981,1,31,0
> 1981,2,1,0
> 1981,2,2,118
> 1981,2,3,0
> 1981,2,4,0
> 1981,2,5,0
> 1981,2,6,12
> 1981,2,7,0
> 1981,2,8,0
> 1981,2,9,46
> 1981,2,10,4
> 1981,2,11,0
> 1981,2,12,0
> 1981,2,13,0
> 1981,2,14,0
> 1981,2,15,0
> 1981,2,16,0
> 1981,2,17,0
> 1981,2,18,0
> 1981,2,19,0
> 1981,2,20,0
> 1981,2,21,4
> 1981,2,22,16
> 1981,2,23,0
> 1981,2,24,0
> 1981,2,25,2
> 1981,2,26,0
> 1981,2,27,0
> 1981,2,28,0
> 1981,3,1,0
> 1981,3,2,0
> 1981,3,3,0
> 1981,3,4,0
> 1981,3,5,0
> 1981,3,6,0
> 1981,3,7,0
> 1981,3,8,0
> 1981,3,9,106
> 1981,3,10,10
> 1981,3,11,0
> 1981,3,12,0
> 1981,3,13,0
> 1981,3,14,0
> 1981,3,15,32
> ...
> For example, if I would like to extract january and february data, and use 1/1/1901 as the origin. How do I use the dates function in R ? I did try to lookup in the manual, but not sure how to apply it?
> This is my code in S-plus.
> define.date1<-function(dt1,mt1,mt2,nn,da)
> {  mt2<-mt2+1
>    start<-julian(mt1, 1, nn, origin=c(month=1, day=1, year=1971))+1
>    end<-julian(mt2, 1, nn, origin=c(month=1, day=1, year=1971))+da
>    a<-dt1[start:end,]
>    am<-as.matrix(a[,5])
> }
> Thank you so much for your kind attention and help.
>
>
>      ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list