Re: [R] how to create a new data given a vector of variable names

2012-05-14 Thread christy
oh, thank you very much! From: Michael Weylandt [via R] To: christy Sent: Tuesday, May 15, 2012 12:28 AM Subject: Re: how to create a new data given a vector of variable names I think you're making this too hard: x[, vars] should do it. For a smaller

Re: [R] how to create a new data given a vector of variable names

2012-05-14 Thread R. Michael Weylandt
I think you're making this too hard: x[, vars] should do it. For a smaller example, consider x <- data.frame(a = 1:5, b = rnorm(5), c = letters[1:5]) x[, c("b","a")] Best, Michael On Tue, May 15, 2012 at 1:12 AM, christy wrote: > hi, please help me on this. I'm very new to R.  I've been fig

Re: [R] how to create a new data given a vector of variable names

2012-05-14 Thread Jorge I Velez
Hi Christy, Try either of the following subset(x, select = vars) x[, vars] HTH, Jorge.- On Tue, May 15, 2012 at 1:12 AM, christy < >wrote: > hi, please help me on this. I'm very new to R. I've been figuring out how > to > do this the whole day, and I could not get the correct R code. > > Sup

[R] how to create a new data given a vector of variable names

2012-05-14 Thread christy
hi, please help me on this. I'm very new to R. I've been figuring out how to do this the whole day, and I could not get the correct R code. Suppose I have a dataframe called x and it consists of 10variables. >x h 1h 2h 3 h 4h 5h 6 h 7