Yes, I think unlist() is still better.
One caution (for all): make sure the columns are all of the same
type/class/mode or you may be in for nasty surprises.
Cheers,
Bert
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
"Data is not information. Information is not knowledge. And k
Thank you. your suggestions all worked.
Best Regards
On Thursday, 30 April 2015, 11:52, Bert Gunter
wrote:
... and if this is what is wanted, somewhat cleaner and more
generalizable for programming would be:
do.call(c, mydata[,1:3])
## where the column indices might have to be a
Hi,
Given that a data frame is a list:
unlist(mydata[, 1:3])
For example:
> all(unlist(iris[, 1:3]) == do.call(c, iris[, 1:3]))
[1] TRUE
Also, note that the returned result in both cases above retains names:
> unlist(iris[, 1:3])
Sepal.Length1 Sepal.Length2 Sepal.Length3 Sepal.Leng
... and if this is what is wanted, somewhat cleaner and more
generalizable for programming would be:
do.call(c, mydata[,1:3])
## where the column indices might have to be adjusted to get the
desired columns.
Cheers,
Bert
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
"Data is
Here are two correct uses of the "stack command", if by that you mean the
stack() function.
> stack( data.frame(a=1:3, b=4:6, c=7:9) )
values ind
1 1 a
2 2 a
3 3 a
4 4 b
5 5 b
6 6 b
7 7 c
8 8 c
9 9 c
> stack( list(a=1:3, b=4:6, c=7:
Hi Olufemi,
I sounds like you have a data frame (let's call it "mydata") with at
least three elements (columns). You may be trying to use c() in this
way:
y1to3<-c(y1,y2,y3)
in which case it won't work. However:
y1to3<-c(mydata$y1,mydata$y2,mydata$y3)
might do what you want, substituting whatev
I am sure you can use c() because columns may be vectors even though vectors
are not columns, but you really need to follow the posting guide and provide a
reproducible example for us to show you how. You might find [1] helpful, in
particular as it describes the use of the dput function to give
Thank you Jeff for your response.
My y1, y2, y3 are actually 3 columns in the data so I cannot use the c()
function to concatenate them. I am confusing the "columns" with vectors. I
actually meant columns.
Any help will be much appreciated
Olufemi
On Wednesday, 29 April 2015, 22:31, Jef
Vectors are not "columns" or "rows". Use the c() function to concatenate
vectors.
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#. ##.#. Live Go...
Hello,I am estimating a system of nonlinear equation where I need to stack my
vector of y. I have data of about 6000units. I tried using the rbind but
instead of having a vector of 1 by 18000, it is giving me a 3 by 6000 so that
my matrix multiplication is non-conformable. The stack command requ
10 matches
Mail list logo