Skip to content
Back to formatted view

Raw Message

Message-ID: <1407097536.91420.YahooMailNeo@web160602.mail.bf1.yahoo.com>
Date: 2014-08-03T20:25:36Z
From: Zilefac Elvis
Subject: Extract particular months from List in R
In-Reply-To: <53DE97A5.6050303@statistik.tu-dortmund.de>

Great! Thanks very much Uwe.
AT.


On Sunday, August 3, 2014 2:12 PM, Uwe Ligges <ligges at statistik.tu-dortmund.de> wrote:


On 03.08.2014 21:23, Zilefac Elvis wrote:
> Hi Uwe,
> Thanks for replying.
> Here is a reproducible example.
> I would like to extract data for the Months of c(6,7,8).
> Output files should have the same number of columns as input files.
>
> Thanks.

[SNIP]

If your data is in an object "dat", then:


lapply(dat, function(x) x[x[["Month"]] %in% 6:8,])

or in order to combine into one data.frame:

do.call("rbind", lapply(dat, function(x) x[x[["Month"]] %in% 6:8,]))




Best,
Uwe Ligges