Thanks for the inputs, but it's not exactly what I want... My problem is, that my timeseries (precipitation) contain lots of NA-values
and when I apply the code: z<- data.frame(a=p1$time.date, precip=p1$m1) #gives a dataframe with precipitation and time (2004-01-01 02:12:00) z<- z[complete.cases(z),] m1.h<-tapply(z$precip, as.POSIXct(trunc(z$a, 'day')), sum) #gives me the daily sum values of this serie (I need to redo this also for hourly values) m1.h<-as.data.frame(m1.h) to get daily summations, the NAs are out and the time series is not continous, therefore I need the time/dates corresponding to the measurement back in the DATA-FRAME! Can I do this, or is the way with tapply/trunc wrong to get hourly/daily summation of my measurements (which are originally in 10 and 15 min period (randomly). really, really thanks a lot... Marc 2007/8/23, Achim Zeileis <[EMAIL PROTECTED]>: > > On Thu, 23 Aug 2007 [EMAIL PROTECTED] wrote: > > > i'm trying to convert a zoo object of the following specifications: > > > > > str(z) > > atomic [1:15642] 0 0 0 0 0 0 0 0 0 0 ... > > - attr(*, "index")='POSIXct', format: chr [1:15642] "2004-09-01 > 02:00:00" "2004-09-01 03:00:00" "2004-09-01 04:00:00" "2004-09-01 05:00:00" > ... > > - attr(*, "frequency")= num 0.000278 > > (Side note 1: The frequency looks suspicious...you probably want a "zoo" > rather than a "zooreg" object.) > > > to convert into a dataframe. the atomic object (or what it is...) is > > (Side note 2: a vector for univariate zoo series, a matrix for > multivariate zoo series.) > > > convertet correctly, but the time attribute in the POSIXct format is > > replaced by an index number > > > > how can i get my data with the corresponding date/time as a second > column? > > Just add it afterwards, e.g., > z <- zoo(cbind(a = 1:5, b = 2:6), as.POSIXct(as.Date("2007-01-01") + > 0:4)) > d <- as.data.frame(z) > d$Date <- time(z) > > (Side note 3: The reason for not including the date is that we wanted the > data to be as similar as possible in the zoo series and the data frame, > e.g., for > lm(a ~ ., data = as.data.frame(z)) > ) > > hth, > Z > > > -- *** Marc Gilgen Plattenstrasse 21 8032 Zürich +41 78 686 06 49 [EMAIL PROTECTED] [[alternative HTML version deleted]]
______________________________________________ R-help@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.