[R] Strage result with an append/strptime combination

Ptit_Bleu ptit_bleu at yahoo.fr
Thu Aug 30 11:26:46 CEST 2007


Hi again,

Just a quick post to propose another solution (without chron) :
strptime function on the whole object and not on each namefile. 

> namefile<-"070707050642.dat"
> namefile<-append(namefile,namefile)
> namefile<-append(namefile,namefile)
> namefile
[1] "070707050642.dat" "070707050642.dat" "070707050642.dat"
"070707050642.dat"
> jourheure<-strptime(namefile,"%d%m%y%H%M%S")
> jourheure
[1] "2007-07-07 05:06:42" "2007-07-07 05:06:42" "2007-07-07 05:06:42"
"2007-07-07 05:06:42"

----------------------------------------------------


Gabor Grothendieck wrote:
> 
> Try chron:
> 
>> library(chron)
>> namefile <- "070707050642.dat"    #day-month-year-hour-minute-second.dat
>> x <- chron(substr(namefile, 1, 6), substr(namefile, 7, 12),
> +   format = c("dmy", "hms"), out.format = c("m/d/y", "h:m:s"))
>> c(x, x)
> [1] (07/07/07 05:06:42) (07/07/07 05:06:42)
> 
> See R News 4/1 Help Desk article for more.
> 
> 

>>
>> Hi,
>>
>> I keep on trying to write some small scripts in order to learn R but even
>> with basic scripts I have problems ...
>>
>> I start with the name of a file which is in fact the time the file has
>> been
>> generated (I cannot change the format). Then I convert namefile with
>> strptime. The problem occurs when I add another time from another file
>> with
>> append. It displays some informations I don't want.
>>
>> I found a post about this problem
>> (http://www.nabble.com/Error-with-strptime-tf3607942.html#a10081942) but
>> I
>> don't understand the solution. I tested as.POSIXct or as.POSIX.lt but it
>> has
>> no effect.
>>
>> Do you have some ideas to solve this problem ?
>> Thank you for your help.
>> Ptit Bleu.
>>
>> -------------------------------------------------------
>>
>> >namefile<-"070707050642.dat"    #day-month-year-hour-minute-second.dat
>> >jourheure<-strptime(namefile,"%d%m%y%H%M%S")
>>
>> > jourheure
>> [1] "2007-07-07 05:06:42"
>>
>> >jourheure<-append(jourheure,jourheure)
>> > jourheure
>> [1] "2007-07-07 05:06:42 Paris, Madrid (heure d'été)" "2007-07-07
>> 05:06:42
>> Paris, Madrid (heure d'été)"
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Strage-result-with-an-append-strptime-combination-tf4347401.html#a12385852
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch 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.
>>
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Strange-result-with-an-append-strptime-combination-tf4347401.html#a12403499
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list