[R] date format conversion problem

Joao Santos jcsantos at student.dei.uc.pt
Wed Oct 24 12:00:12 CEST 2007


Hello Ben,

First of all thanks for the reply,and sorry because I haven't replied early.
In this time I find another form to create the "my time", like this:

bbrass = scan("C:/Program Files/R/data
PTIN/bbrass_client_2471_pool_72644_percent_in_use_500_NA.dat")
regts.start = ISOdatetime(2006, 7, 1, hour=0, min=0, sec=0, tz="GMT")	#2006
07 01 00
regts.end = ISOdatetime(2006, 7, 22, hour=2, min=0, sec=0, tz="GMT")	#2006
07 22 02
regts.zoo <- zooreg(bbrass, regts.start, regts.end, deltat=3600)
summary(regts.zoo)

     Index                       regts.zoo 
 Min.   :2006-07-01 00:00:00   Min.   :48  
 1st Qu.:2006-07-06 06:15:00   1st Qu.:58  
 Median :2006-07-11 12:30:00   Median :62  
 Mean   :2006-07-11 12:30:00   Mean   :65  
 3rd Qu.:2006-07-16 18:45:00   3rd Qu.:74  
 Max.   :2006-07-22 01:00:00   Max.   :81  
                               NA's   :40
 
Then I create a time serie and the REGUL fuction works fine.

About your sugestions: 
(1) R version 
In using R version 2.5.1 (2007-06-27) 
(2) meaningful subject line would be nice
Sorry, but this was my first message to the list and only after I post I
realize that the subject was empty.   


Ben Bolker wrote:
> 
> 
> 
> Joao Santos-7 wrote:
>> 
>> Hello,
>> 
>> I problem is in the format of the date, my time series is like this:
>> 
>> [snip]
>> 
>> When I attempt to format the time like this:
>> 
>> A <- read.table("file", sep="\t", col.names=c("date", "my1", "my2",
>> "my3"))
>> temp <- as.Date(A$date, format="%Y%m%d%H")
>> temp
>> 
>> I get
>> 
>>   [1] "4403-05-21" "4403-05-22" "4403-05-23" "4403-05-24" "4403-05-25"
>> [snip ...]
>> 
>> 
> 
>  I saved your data (in a space-separated format rather than
> tab-separated, but that shouldn't matter)
> 
> A <- read.table("timeser.dat",
>                 col.names=c("date", "my1", "my2", "my3"))
> 
> temp <- as.Date(as.character(A$date), format="%Y%m%d%H")
> 
>   Oddly enough, when I do 
> 
> as.Date(A$date, format="%Y%m%d%H")
> 
> or
> 
> as.Date(A$date)
> 
>   I get
> 
> Error in as.Date.default(A$date) : 
>   do not know how to convert 'A$date' to class "Date"
> 
>   rather than a nonsensical answer -- what version of R
> are you using?  (e.g. what are the results of sessionInfo() ?)
> Although it looks like the results you get might be the results of
> translating numeric directly into a date ... ?
> 
>  [thanks for the reproducible example, but (1) R version and
> (2) meaningful subject line would be nice.  Also, good to specify
> that regul() is from the pastecs package ]
> 
>   Ben Bolker
> 
> 
> 



-- 
View this message in context: http://www.nabble.com/%28no-subject%29-tf4602032.html#a13382752
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list