Re: [R] Calling on certina columns

2012-05-23 Thread David Winsemius


On May 23, 2012, at 5:47 PM, Chris Burns wrote:

I'm trying to run a regression on certain columns.  The columns are  
named
"Cat_1", "Cat_2" etc.  Is there a way to call upon all of the  
columns that

contain "Cat"?



lm( y ~ . , data=dfrm[, c("y", grep("Cat", names(dfrm), value=TRUE) ] )

OR:

lm (y ~ . , data=dfrm[,  grep("Cat|y", names(dfrm) ) ] )




--

David Winsemius, MD
West Hartford, CT

__
R-help@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.


[R] Calling on certina columns

2012-05-23 Thread Chris Burns
I'm trying to run a regression on certain columns.  The columns are named
"Cat_1", "Cat_2" etc.  Is there a way to call upon all of the columns that
contain "Cat"?

Thanks,

Chris

[[alternative HTML version deleted]]

__
R-help@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.