[R] Filter/Ceiling for unwanted data - zoo

Gabor Grothendieck ggrothendieck at gmail.com
Tue Mar 6 01:06:18 CET 2012


On Mon, Mar 5, 2012 at 3:33 PM, knavero <knavero at gmail.com> wrote:
> Here's my script:
>
> http://pastebin.com/zx3TCtXg
>
> I want to draw attention to the code block where the read in of the raw data
> is located. Is there a function that filters out unwanted data with respect
> to a ceiling limit. For example, I want to remove any value over 500 kW in
> the rawCool variable. Any ideas where to go with that? I figure it would be
> an argument within read.zoo or an external function that manipulates the zoo
> vector that was read in prior. I plan on looking into the zoo FAQ and the R
> manual '?'. Any help pushing me towards the right direction is much
> appreciated.
>

If z is a zoo object then any of the last three lines returns those
rows of z for which a > 3 and b > 3:

library(zoo)
z <- zoo(cbind(a = 1:10, b = 10:1), as.Date("2000-01-01") + 0:9)

z[ z$a > 3 & z$b > 3, ]
# or
with(z, z[a > 3 & b > 3, ])
# or
subset(z, a > 3 & b > 3)

Also, please read the last line of every message to r-help and provide
examples that are reproducible/self-contained and minimal.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list