Re: [R] Stacking of vectors to form a column vector

2015-04-30 Thread Bert Gunter
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

Re: [R] Stacking of vectors to form a column vector

2015-04-30 Thread Olufemi Bolarinwa
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

Re: [R] Stacking of vectors to form a column vector

2015-04-30 Thread Marc Schwartz
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

Re: [R] Stacking of vectors to form a column vector

2015-04-30 Thread Bert Gunter
... 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

Re: [R] Stacking of vectors to form a column vector

2015-04-30 Thread MacQueen, Don
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:

Re: [R] Stacking of vectors to form a column vector

2015-04-29 Thread Jim Lemon
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

Re: [R] Stacking of vectors to form a column vector

2015-04-29 Thread Jeff Newmiller
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

Re: [R] Stacking of vectors to form a column vector

2015-04-29 Thread Olufemi Bolarinwa
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

Re: [R] Stacking of vectors to form a column vector

2015-04-29 Thread Jeff Newmiller
Vectors are not "columns" or "rows". Use the c() function to concatenate vectors. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go...

[R] Stacking of vectors to form a column vector

2015-04-29 Thread Olufemi Bolarinwa
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