Re: [R] Listing Variables

2006-05-04 Thread Gabor Grothendieck
On 5/4/06, Farrel Buchinsky <[EMAIL PROTECTED]> wrote: > bogdan romocea gmail.com> writes: > > > > > Here's an example. > > dfr <- data.frame(A1=1:10,A2=21:30,B1=31:40,B2=41:50) > > vars <- colnames(dfr) > > for (v in vars[grep("B",vars)]) print(mean(dfr[,v])) > > At first I did not know why you h

Re: [R] Listing Variables

2006-05-04 Thread Farrel Buchinsky
bogdan romocea gmail.com> writes: > > Here's an example. > dfr <- data.frame(A1=1:10,A2=21:30,B1=31:40,B2=41:50) > vars <- colnames(dfr) > for (v in vars[grep("B",vars)]) print(mean(dfr[,v])) At first I did not know why you had bothered with the (dfr[,v])) part of the command. I thought you sh

Re: [R] Listing Variables

2006-05-03 Thread Farrel Buchinsky
"Uwe Ligges" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > vnames <- paste("Height", 1:20, sep=".") Interesting but not suitable. It creates a name even if such a variable does not exist. I have 6000 variables. The numeric component of the variable name goes from 0 to about 100

Re: [R] Listing Variables

2006-05-03 Thread bogdan romocea
y > Sent: Wednesday, May 03, 2006 10:46 AM > To: r-help@stat.math.ethz.ch > Subject: [R] Listing Variables > > How does one create a vector whose contents is the list of > variables in a > dataframe pertaining to a particular pattern? > This is so simple but I cannot find

Re: [R] Listing Variables

2006-05-03 Thread Gabor Grothendieck
Column names in iris that contain the string Sepal: grep("Sepal", names(iris), value = TRUE) On 5/3/06, Farrel Buchinsky <[EMAIL PROTECTED]> wrote: > How does one create a vector whose contents is the list of variables in a > dataframe pertaining to a particular pattern? > This is so simple but

Re: [R] Listing Variables

2006-05-03 Thread Uwe Ligges
Farrel Buchinsky wrote: > How does one create a vector whose contents is the list of variables in a > dataframe pertaining to a particular pattern? > This is so simple but I cannot find a straightforward answer. > I want to be able to pass the contents of that list to a "for" loop. > > So let us

Re: [R] Listing Variables

2006-05-03 Thread Marc Schwartz (via MN)
On Wed, 2006-05-03 at 10:46 -0400, Farrel Buchinsky wrote: > How does one create a vector whose contents is the list of variables in a > dataframe pertaining to a particular pattern? > This is so simple but I cannot find a straightforward answer. > I want to be able to pass the contents of that lis

[R] Listing Variables

2006-05-03 Thread Farrel Buchinsky
How does one create a vector whose contents is the list of variables in a dataframe pertaining to a particular pattern? This is so simple but I cannot find a straightforward answer. I want to be able to pass the contents of that list to a "for" loop. So let us assume that one has a dataframe whose