Re: [R] simple usage of "for"

2008-02-19 Thread Hans Ekbrand
On Tue, Feb 19, 2008 at 10:04:13AM -0500, Duncan Murdoch wrote: > On 2/19/2008 9:24 AM, Hans Ekbrand wrote: [...] > > I tried the following small code snippet which I copied from the > > "Introduction to R": > > > >> for (i in 2:length(meriter)) { table(meriter[[1]], meriter[[i]]) } > > Where d

Re: [R] simple usage of "for"

2008-02-19 Thread Hans Ekbrand
On Tue, Feb 19, 2008 at 04:52:19PM +0200, K. Elo wrote: > Hi, > > Hans Ekbrand wrote (19.2.2008): > > I tried the following small code snippet which I copied from the > > > > "Introduction to R": > > > for (i in 2:length(meriter)) { table(meriter[[1]], meriter[[i]]) } > > Try: > for (i in 2:lengt

Re: [R] simple usage of "for"

2008-02-19 Thread Duncan Murdoch
On 2/19/2008 9:24 AM, Hans Ekbrand wrote: > Hi list > > I have a data frame I would like to loop over. To begin with I would > like crosstabulations using the first variabel in the data frame, > which is called "meriter". > >> table(meriter[[1]], meriter[[3]]) >

Re: [R] simple usage of "for"

2008-02-19 Thread K. Elo
Hi, Hans Ekbrand wrote (19.2.2008): > I tried the following small code snippet which I copied from the > > "Introduction to R": > > for (i in 2:length(meriter)) { table(meriter[[1]], meriter[[i]]) } Try: for (i in 2:length(meriter)) { print(table(meriter[[1]], meriter[[i]])) } Kind regards, Kim

[R] simple usage of "for"

2008-02-19 Thread Hans Ekbrand
Hi list I have a data frame I would like to loop over. To begin with I would like crosstabulations using the first variabel in the data frame, which is called "meriter". > table(meriter[[1]], meriter[[3]])