[R] Subsetting zoo object with a vector of time values.
I have a zoo object for which I would like to subset using a vector of time values. For example, I have the following time values represented in my zoo object. -50.000 -49.996 -49.995 -49.960 -49.956 -49.955 -49.920 -49.916 -49.915 -49.880 and would like to get observations corresponding to times -50 -49.96 -49.92 -49.88. What can I do without using the lapply or which functions? Thank you. Todd Remund __ 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.
Re: [R] Subsetting zoo object with a vector of time values.
On Tue, 21 Aug 2007, Todd Remund wrote: I have a zoo object for which I would like to subset using a vector of time values. For example, I have the following time values represented in my zoo object. -50.000 -49.996 -49.995 -49.960 -49.956 -49.955 -49.920 -49.916 -49.915 -49.880 and would like to get observations corresponding to times -50 -49.96 -49.92 -49.88. What can I do without using the lapply or which functions? Use the window() function: z - zoo(1:10, c(-50.000, -49.996, -49.995, -49.960, -49.956, -49.955, -49.920, -49.916, -49.915, -49.880)) window(z, c(-50, -49.96, -49.92, -49.88)) hth, Z Thank you. Todd Remund __ 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. __ 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.
Re: [R] Subsetting zoo object with a vector of time values.
See ?window.zoo e.g. library(zoo) # create test data tt - c(-50, -49.996, -49.995, -49.96, -49.956, -49.955, -49.92, -49.916, -49.915, -49.88) z - zoo(seq_along(tt), tt) window(z, c(-50, -49.96, -49.92, -49.88)) On 8/21/07, Todd Remund [EMAIL PROTECTED] wrote: I have a zoo object for which I would like to subset using a vector of time values. For example, I have the following time values represented in my zoo object. -50.000 -49.996 -49.995 -49.960 -49.956 -49.955 -49.920 -49.916 -49.915 -49.880 and would like to get observations corresponding to times -50 -49.96 -49.92 -49.88. What can I do without using the lapply or which functions? Thank you. Todd Remund __ 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. __ 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.