> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Lara Poplarski
> Sent: Tuesday, May 17, 2011 4:14 PM
> To: r-help@r-project.org
> Subject: Re: [R] subsetting a list of dataframes
>
> Thank you all, th
On May 17, 2011, at 7:13 PM, Lara Poplarski wrote:
Thank you all, this is exactly what I had in mind, except that I
still have
to get my head around apply et al. Back to the books for me then!
Read the lapply( ...) call as:
"For every element in the object named `data`, send that element
Thank you all, this is exactly what I had in mind, except that I still have
to get my head around apply et al. Back to the books for me then!
Lara
On Tue, May 17, 2011 at 2:41 PM, Jannis wrote:
> Have a look at lapply(). Something like:
>
> entries.with.nrows=lapply(data,function(x)dim(x)[1]>1)
Have a look at lapply(). Something like:
entries.with.nrows=lapply(data,function(x)dim(x)[1]>1)
should give you a vector with the elements of the list that you seek marked
with TRUE.
This vector can then be used to extract a subset from your list by:
data.reduced=data[entries.with.nrows]
Or s
On 18/05/11 08:24, Lara Poplarski wrote:
Hello All,
I have a list of dataframes, and I need to subset it by keeping only those
dataframes in the list that meet a certain criterion. Specifically, I need
to generate a second list which only includes those dataframes whose number
of rows is> 1.
C
shouldKeep <- sapply(listOfDataFrames, function(df)nrow(df)>1)
listOfDataFrames[shouldKeep]
or, compressed to get rid of the intermediate variable
listOfDataFrames[sapply(listOfDataFrames, function(df)nrow(df)>1)]
If you are writing production code and there is any chance that
listOfDataFra
Hi Lara,
You might try the following (untested):
yourlistofdataframes[sapply(yourlistofdataframes, function(d) nrow(d) > 1)]
HTH,
Jorge
On Tue, May 17, 2011 at 4:24 PM, Lara Poplarski <> wrote:
> Hello All,
>
> I have a list of dataframes, and I need to subset it by keeping only those
> dataf
7 matches
Mail list logo