Re: [R] Listing Variables

2006-05-04 Thread Farrel Buchinsky
bogdan romocea br44114 at 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

Re: [R] Listing Variables

2006-05-04 Thread Gabor Grothendieck
On 5/4/06, Farrel Buchinsky [EMAIL PROTECTED] wrote: bogdan romocea br44114 at 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

[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

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 list

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 assume

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 I

Re: [R] Listing Variables

2006-05-03 Thread bogdan romocea
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 a straightforward answer. I want to be able to pass the contents of that list

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 1000.