: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 is a cbind of dog, cat, and tree.
This is a toy
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 example.
-Original Message-
From: erinm.hodg...@gmail.com
Sent: Thu, 23 Apr 2015 18:41:05 -0400
To: r-h...@stat.math.ethz.ch
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
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 end up with a matrix
, cat,
tree, big.char)))
John Kane
Kingston ON Canada
-Original Message-
From: erinm.hodg...@gmail.com
Sent: Thu, 23 Apr 2015 18:41:05 -0400
To: r-h...@stat.math.ethz.ch
Subject: [R] cbind question, please
Hello!
I have a cbind type question, please: Suppose I have
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 erinm.hodg...@gmail.com wrote:
G'day Erin,
On Thu, 23 Apr 2015 20:51:18 -0400
Erin Hodgess erinm.hodg...@gmail.com 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
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
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
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
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 Bowman
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, 2015
On Apr 23, 2015, at 5:41 PM, Erin Hodgess erinm.hodg...@gmail.com 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
: 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 end up with a matrix that is a cbind of dog, cat
These are great! Thank you!
On Thu, Apr 23, 2015 at 7:14 PM, William Dunlap wdun...@tibco.com 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
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 variables.
I
16 matches
Mail list logo