On Thu, Apr 29, 2010 at 11:44 AM, Carol Gao <carol.g...@gmail.com> wrote:
> I tried your new lines with some random time, it seems to be working > perfectly well, just as follows: > > z <- strptime("20/2/06 23:16:16.683", "%d/%m/%y %H:%M:%OS") > > modifyList(z, list(hour = z$hour + 11)) > [1] "2006-02-21 10:16:16" > > Now it seems that I have some problem with my Time vector. As Time was > created by the following code: > Time <- paste(anz$Date.G.,anz$Time.G.) > The original data looks like the following with each row correspond to > each. > Date.G. > 01-DEC-2008 > 01-DEC-2008 > 02-DEC-2008 > 03-DEC-2008 > 04-DEC-2008 > ... > > Time.G. > 00:03:57.398 > 00:04:03.778 > 00:04:38.639 > 00:04:38.639 > 00:04:38.639 > ... > Somehow, I can't read Time in strptime(Time,"%d-%b-%Y %H:%M:%OS"). Do you > know what was wrong with it? > Why not? anz <- data.frame(Date.G = c("01-DEC-2008", "01-DEC-2008","02-DEC-2008","03-DEC-2008","04-DEC-2008"), Time.G = c("00:03:57.398","00:04:03.778","00:04:38.639","00:04:38.639","00:04:38.639")) Time <- strptime(paste(anz$Date.G, anz$Time.G), '%d-%b-%Y %H:%M:%S') modifyList(Time, list(hour = Time$hour + 11)) > > Sorry for asking such questions, as I am quite new to R. Thanks for helping > me out. > > Carol > > > > > On Fri, Apr 30, 2010 at 12:16 AM, Henrique Dallazuanna > <www...@gmail.com>wrote: > >> Ops, >> >> I sent to you a wrong code, try this indeed: >> >> Time2 <- strptime(Time, '%d-%b-%Y %H:%M:%S') >> >> modifyList(Time2, list(hour = Time2$hour + 11)) >> >> On Thu, Apr 29, 2010 at 11:14 AM, Carol Gao <carol.g...@gmail.com> wrote: >> >>> Appreciate it! I was trying on the code you sent, then some error codes >>> turned up: >>> >>> The first line runs ok, the second line: >>> >>> >>> > modifyList(Time2, list(hour = Time2$hour + 11)) >>> Error in Time2$hour : $ operator is invalid for atomic vectors >>> >>> The time format I used for reading the Time vector is "%d-%b-%Y >>> %H:%M:%OS". Should I change any code above? >>> >>> Carol >>> >>> >>> >>> >>> On Thu, Apr 29, 2010 at 11:47 PM, Henrique Dallazuanna <www...@gmail.com >>> > wrote: >>> >>>> Try this: >>>> >>>> Time2 <- gsub("\\.*", "", tolower(Time)) >>>> modifyList(Time2, list(hour = Time2$hour + 11)) >>>> >>>> >>>> On Thu, Apr 29, 2010 at 10:33 AM, Carol Gao <carol.g...@gmail.com>wrote: >>>> >>>>> Hi there, >>>>> >>>>> I've got a column vector in a csv file as follows, and I need to add 11 >>>>> hours to each of them. Is there a way that I can do it? (The actual >>>>> file >>>>> size is much bigger than this.) >>>>> >>>>> Time >>>>> "01-DEC-2008 00:00:28.611" >>>>> "01-DEC-2008 00:00:43.155" >>>>> "01-DEC-2008 00:01:06.677" >>>>> "01-DEC-2008 00:01:06.677" >>>>> "01-DEC-2008 00:01:06.677" >>>>> "01-DEC-2008 00:01:06.919" >>>>> "01-DEC-2008 00:23:46.452" >>>>> "02-DEC-2008 00:03:17.646" >>>>> "02-DEC-2008 00:03:17.652" >>>>> "03-DEC-2008 00:15:11.485" >>>>> "03-DEC-2008 00:18:44.652" >>>>> "03-DEC-2008 00:22:17.447" >>>>> >>>>> Thank you in advance. >>>>> >>>>> Cheers, >>>>> >>>>> Carol >>>>> >>>>> [[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. >>>>> >>>> >>>> >>>> >>>> -- >>>> Henrique Dallazuanna >>>> Curitiba-Paraná-Brasil >>>> 25° 25' 40" S 49° 16' 22" O >>>> >>> >>> >> >> >> -- >> Henrique Dallazuanna >> Curitiba-Paraná-Brasil >> 25° 25' 40" S 49° 16' 22" O >> > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[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.