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
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
"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
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
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
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
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
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