Re: [R] applying an operation for several dataframes

From: jim holtman <jholtman_at_gmail.com>
Date: Sat, 22 Nov 2008 16:24:45 -0500

?get

names <- c('c', 'cc')
for (i in names){

    print(nrow(get(i)))
}

On Sat, Nov 22, 2008 at 4:06 PM, Georg Ehret <georgehret_at_gmail.com> wrote:
> Dear R community,
> I am trying to apply a simple operation to several dataframes (e.g.
> nrow) and cannot get the looping to work. My objective is to get an output
> that indicates me the number of rows for every dataframe.
>
>> c
> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
> 1 1 11 21 31 41 51 61 71 81 91
> 2 2 12 22 32 42 52 62 72 82 92
> 3 3 13 23 33 43 53 63 73 83 93
> 4 4 14 24 34 44 54 64 74 84 94
> 5 5 15 25 35 45 55 65 75 85 95
>> cc
> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
> 1 1 11 21 31 41 51 61 71 81 91
> 2 2 12 22 32 42 52 62 72 82 92
> 3 3 13 23 33 43 53 63 73 83 93
> 4 4 14 24 34 44 54 64 74 84 94
> 5 5 15 25 35 45 55 65 75 85 95
> 6 6 16 26 36 46 56 66 76 86 96
> 7 7 17 27 37 47 57 67 77 87 97
> 8 8 18 28 38 48 58 68 78 88 98
> 9 9 19 29 39 49 59 69 79 89 99
> 10 10 20 30 40 50 60 70 80 90 100
>> names<-c("c","cc")
>> for(i in names){nrow(i)}
>
> Thank you!
> Georg.
> *****************************
> Georg Ehret
> georg_at_rhone.ch
> Geneva University Hospital
> Switzerland
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

______________________________________________
R-help_at_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.
Received on Sat 22 Nov 2008 - 21:27:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 23 Nov 2008 - 03:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive