Dear All, The following function gives me what I wanted. The input of function is one value and this push me to use sapply function to call it.
Is there a better way of doing this? #==================================================== day <- function(x){ if(x== 60) { y = "29 Feb" } if(x < 60){ y = format(strptime(x, format = "%j"), format ="%d-%b") } if(x > 60){ y = format(strptime(x - 1, format = "%j"), format ="%d-%b") } y } sapply(Samaru$Start,day) [1] "17-Apr" "27-Apr" "24-Apr" "04-Jun" "25-Apr" "13-May" "22-Apr" "05-May" "27-Apr" "13-May" "27-Apr" #======================================================= On Thu, Oct 9, 2014 at 3:48 PM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > On 09/10/2014, 8:27 AM, PIKAL Petr wrote: > > Hi > > > >> -----Original Message----- > >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > >> project.org] On Behalf Of Frederic Ntirenganya > >> Sent: Thursday, October 09, 2014 1:32 PM > >> To: Jim Lemon > >> Cc: r-help@r-project.org > >> Subject: Re: [R] Changing date format > >> > >> This idea substract 1 for the all column which is not what i want. > >> > >> We know that the leap years have 366 days. I don't need to change > >> anything on them > >> > >> the non-leap years have 365 days. This is what i want to change to be > >> 366 days rather than 365 days. > > > > But this is a question of calendar reform not R. I must admit it would > be a tough job as leap day is needed to stay in tune with solar year. Your > suggestion would quickly result in out of sync with the Sun. > > R Core is powerful, but I doubt if we could reform the calendar in this > way. > > And I'd be against it in any case: I like to swim on my summer > vacations, but if August slipped into the winter, the lakes around here > would be frozen. > > Duncan Murdoch > -- Frederic Ntirenganya Maseno University, Kenya. Mobile:(+254)718492836 Email: fr...@aims.ac.za https://sites.google.com/a/aims.ac.za/fredo/ [[alternative HTML version deleted]] ______________________________________________ R-help@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.