Re: [R] cbind question, please

2015-04-24 Thread David Kienle
Hello Erin, I think you have explain your goal more detailed. Maybe I am completely lost but as far as I understand now you only need the command cbind: m1 <- cbind(dog, dat, tree) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 But I can't imagine that is the solution yo

Re: [R] cbind question, please

2015-04-24 Thread William Dunlap
You could do something tricky like > do.call(cbind, lapply(big.char, as.name)) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 but you are usually better off creating these things as part of a list and passing that to do.call(cbind, list). There is a slight danger

Re: [R] cbind question, please

2015-04-24 Thread Rolf Turner
I am amazed at the number of rather obtuse misunderstandings of the actual nature of Erin's question. The suggestion that Erin should read the intro to R made me smile. Erin is a long time and highly sophisticated user of R; she has no need to read the intro. The person who made that sugge

Re: [R] cbind question, please

2015-04-24 Thread Martin Maechler
f Of Erin Hodgess > Sent: Friday, 24 April 2015 10:41a > To: R help > Subject: [R] cbind question, please > Hello! > I have a cbind type question, please: Suppose I have the following: > dog <- 1:3 > cat <- 2:4 > tree <- 5:7 >

Re: [R] cbind question, please

2015-04-24 Thread Berwin A Turlach
G'day Erin, On Thu, 23 Apr 2015 20:51:18 -0400 Erin Hodgess wrote: > Here is the big picture. I have a character vector with all of the > names of the variables in it. > > I want to "cbind" all of the variables to create a matrix. > > Doing 3 is straightforward, but many, not so much. So I g

Re: [R] cbind question, please

2015-04-24 Thread Michael Hannon
Is this what you're looking for? > dog <- 1:3 > bat <- 2:4 > tree <- 5:7 > big.char <- c("dog","bat","tree") > do.call(cbind,lapply(big.char, get)) [,1] [,2] [,3] [1,]125 [2,]236 [3,]347 > On Thu, Apr 23, 2015 at 3:41 PM, Erin Hodgess wrote: > Hello!

Re: [R] cbind question, please

2015-04-24 Thread Kehl Dániel
:41 To: R help Tárgy: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog <- 1:3 cat <- 2:4 tree <- 5:7 and a character vector big.char <- c("dog","cat","tree") I want to end up with a matrix that

Re: [R] cbind question, please

2015-04-24 Thread Rolf Turner
On 24/04/15 10:41, Erin Hodgess wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog <- 1:3 cat <- 2:4 tree <- 5:7 and a character vector big.char <- c("dog","cat","tree") I want to end up with a matrix that is a "cbind" of dog, cat, and tree. This is a toy e

Re: [R] cbind question, please

2015-04-24 Thread John Kane
ot;4", "5", "6", "7", "dog", "cat", "tree"), .Dim = 3:4, .Dimnames = list(NULL, c("dog", "cat", "tree", "big.char"))) John Kane Kingston ON Canada > -Original Message- > From: eri

Re: [R] cbind question, please

2015-04-24 Thread Erin Hodgess
tructure(c("1", "2", "3", "2", "3", "4", "5", "6", "7", "dog", > "cat", "tree"), .Dim = 3:4, .Dimnames = list(NULL, c("dog", "cat", > "t

Re: [R] cbind question, please

2015-04-24 Thread Marc Schwartz
On Apr 23, 2015, at 5:41 PM, Erin Hodgess wrote: > > Hello! > > I have a cbind type question, please: Suppose I have the following: > > dog <- 1:3 > cat <- 2:4 > tree <- 5:7 > > and a character vector > big.char <- c("dog","cat","tree") > > I want to end up with a matrix that is a "cbind" of

Re: [R] cbind question, please

2015-04-24 Thread Steve Taylor
: Friday, 24 April 2015 10:41a To: R help Subject: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog <- 1:3 cat <- 2:4 tree <- 5:7 and a character vector big.char <- c("dog","cat","tree") I want to

Re: [R] cbind question, please

2015-04-24 Thread Erin Hodgess
These are great! Thank you! On Thu, Apr 23, 2015 at 7:14 PM, William Dunlap wrote: > You could do something tricky like > > do.call(cbind, lapply(big.char, as.name)) >dog cat tree > [1,] 1 25 > [2,] 2 36 > [3,] 3 47 > but you are usually better off creat

Re: [R] cbind question, please

2015-04-24 Thread Clint Bowman
Perhaps: dog <- 1:3 cat <- 2:4 tree <- 5:7 big.char <- cbind(dog,cat,tree) big.char dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 colnames(big.char)<-c("dog","cat","tree") big.char dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 Clint Bowma

Re: [R] cbind question, please

2015-04-24 Thread Jim Lemon
Hi Erin, Well, if I do this: dog <- 1:3 cat <- 2:4 tree <- 5:7 dct<-cbind(dog,cat,tree) I get this: dct dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 If I assume that you want to include the character vector as well: rownames(dct)<-big.char dct Jim On Fri, Apr 24, 2

[R] cbind question, please

2015-04-23 Thread Erin Hodgess
Hello! I have a cbind type question, please: Suppose I have the following: dog <- 1:3 cat <- 2:4 tree <- 5:7 and a character vector big.char <- c("dog","cat","tree") I want to end up with a matrix that is a "cbind" of dog, cat, and tree. This is a toy example. There will be a bunch of variabl