Hello, I problem is in the format of the date, my time series is like this: 2006070100 1244 61 62 2006070101 1221 60 60 2006070102 1214 60 60 2006070103 1194 59 59 2006070104 1182 58 58 2006070105 1178 58 58 2006070106 1176 58 58 2006070107 1173 58 58 2006070108 1179 58 59 2006070109 1246 61 62 …. 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" [6] "4403-05-26" "4403-05-27" "4403-05-28" "4403-05-29" "4403-05-30" Another problem is in REGUL, I using the variables created in the extraction of the data but the regulation is not possible REGUL Ts.regul<-regul(A$date, y=A$my2, xmin=2006070100, n=800, units="hours", frequency=1, deltat=1/3600, datemin=NULL, dateformat="m/d/Y", tol=NULL, tol.type="both", methods="linear", rule=1, f=0, periodic=FALSE, window=(2006080316 - 2006070100)/(800 - 1), split=100, specs=NULL) I think if the question is resolved the function REGUL will work to. Can someone help me? I new to this forum and in the utilisation of R. Thanks for the help in advance, João Santos [[alternative HTML version deleted]]
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#a13141435 Sent from the R help mailing list archive at Nabble.com.
Joao, I can't reproduce your results. Try: str(A) When I read in the data frame A, I see> str(A)'data.frame': 10 obs. of 4 variables: $ date: int 2006070100 2006070101 2006070102 2006070103 2006070104 2006070105 2006070106 2006070107 2006070108 2006070109 $ my1 : int 1244 1221 1214 1194 1182 1178 1176 1173 1179 1246 $ my2 : int 61 60 60 59 58 58 58 58 58 61 $ my3 : int 62 60 60 59 58 58 58 58 59 62> temp <- as.Date(A$date, format="%Y%m%d%H")Error in as.Date.default(A$date, format = "%Y%m%d%H") : do not know how to convert 'A$date' to class "Date" Which is a tip off that you need to force date to be a character, either at read.table time or by doing:> temp <- as.Date(as.character(A$date), format="%Y%m%d%H") > temp[1] "2006-07-01" "2006-07-01" "2006-07-01" "2006-07-01" "2006-07-01" [6] "2006-07-01" "2006-07-01" "2006-07-01" "2006-07-01" "2006-07-01" -- HTH, Jim Porzak Responsys, Inc. San Francisco, CA http://www.linkedin.com/in/jimporzak On 10/10/07, Joao Santos <jcsantos@student.dei.uc.pt> wrote:> > Hello, > > > > I problem is in the format of the date, my time series is like this: > > 2006070100 1244 61 62 > > 2006070101 1221 60 60 > > 2006070102 1214 60 60 > > 2006070103 1194 59 59 > > 2006070104 1182 58 58 > > 2006070105 1178 58 58 > > 2006070106 1176 58 58 > > 2006070107 1173 58 58 > > 2006070108 1179 58 59 > > 2006070109 1246 61 62 > > …. > > > > 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" > > [6] "4403-05-26" "4403-05-27" "4403-05-28" "4403-05-29" "4403-05-30" > > > > Another problem is in REGUL, I using the variables created in the > extraction > of the data but the regulation is not possible > > > > REGUL > > Ts.regul<-regul(A$date, y=A$my2, xmin=2006070100, n=800, units="hours", > frequency=1, > > deltat=1/3600, datemin=NULL, dateformat="m/d/Y", tol=NULL, > > tol.type="both", methods="linear", rule=1, f=0, periodic=FALSE, > > window=(2006080316 - 2006070100)/(800 - 1), split=100, specs=NULL) > > > > I think if the question is resolved the function REGUL will work to. > > Can someone help me? I new to this forum and in the utilisation of R. > > > > > > Thanks for the help in advance, > > > > João Santos > > > > > > > [[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. > >[[alternative HTML version deleted]]
Hello, First of all, thanks everyone that reply to my questions and I sorry to spend so many time to reply. I'm find a way to treat this problem using the zoo package: 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) #I won't the time to the hour... 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 series and the regul fuction (pastecs package) works fine. Thanks again for the replies, Joao Santos Joao Santos wrote:> > Hello, > > > > I problem is in the format of the date, my time series is like this: > > 2006070100 1244 61 62 > > 2006070101 1221 60 60 > > 2006070102 1214 60 60 > > 2006070103 1194 59 59 > > 2006070104 1182 58 58 > > 2006070105 1178 58 58 > > 2006070106 1176 58 58 > > 2006070107 1173 58 58 > > 2006070108 1179 58 59 > > 2006070109 1246 61 62 > >.> > > > 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" > > [6] "4403-05-26" "4403-05-27" "4403-05-28" "4403-05-29" "4403-05-30" > > > > Another problem is in REGUL, I using the variables created in the > extraction > of the data but the regulation is not possible > > > > REGUL > > Ts.regul<-regul(A$date, y=A$my2, xmin=2006070100, n=800, units="hours", > frequency=1, > > deltat=1/3600, datemin=NULL, dateformat="m/d/Y", tol=NULL, > > tol.type="both", methods="linear", rule=1, f=0, periodic=FALSE, > > window=(2006080316 - 2006070100)/(800 - 1), split=100, specs=NULL) > > > > I think if the question is resolved the function REGUL will work to. > > Can someone help me? I new to this forum and in the utilisation of R. > > > > > > Thanks for the help in advance, > > > > Jo?o Santos > > > > > > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. > >-- View this message in context: http://www.nabble.com/%28no-subject%29-tf4602032.html#a13382815 Sent from the R help mailing list archive at Nabble.com.