[R] Quick q. on lists

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Aug 19 17:49:45 CEST 2010


You need sapply

max(sapply(myList, nrow))

Thierry

------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey
  

> -----Oorspronkelijk bericht-----
> Van: r-help-bounces op r-project.org 
> [mailto:r-help-bounces op r-project.org] Namens Jonathan
> Verzonden: donderdag 19 augustus 2010 17:42
> Aan: r-help
> Onderwerp: [R] Quick q. on lists
> 
> Hi All,
>     Anyone know how to quickly query some summary information 
> on the components of a list?
> 
> For example, I have a list that contains dataframes
> (originally generated by using split() on one large data frame).
> 
> 
> I simply want to know the number of rows in the longest 
> dataframe from the list.
> 
> Example, if my list has 3 data frames, and the first has 2 
> rows, the second 8 rows, and the third 3 rows, I want to ask 
> something like:
> 
> 
> max(nrow(myList))
> which would ideally return "8".
> 
> 
> but this is obviously wrong syntax.
> 
> Currently, I'm looping through each of the data frames in the 
> list, searching for the max rows, but I'm sure there must be 
> a faster way.
> 
> Thanks,
> Jonatahn
> 
> ______________________________________________
> R-help op r-project.org 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.
> 

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.



More information about the R-help mailing list