[R] Converting from a dataset to a single "column"
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Jan 23 20:00:14 CET 2006
r user <ruser2006 at yahoo.com> writes:
> I have a dataset of 3 “columns” and 5 “rows”.
>
> temp<-data.frame(col1=c(5,10,14,56,7),col2=c(4,2,8,3,34),col3=c(28,4,52,34,67))
>
> I wish to convert this to a single “column”, with
> column 1 on “top” and column 3 on “bottom”.
>
> i.e.
>
> 5
> 10
> 14
> 56
> 7
> 4
> 2
> 8
> 3
> 34
> 28
> 4
> 52
> 34
> 67
>
> Are there any functions that do this, and that will
> work well on much larger datasets (e.g. 1000 rows,
> 6000 columns)?
unlist(temp,use.names=FALSE)
Did you really mean "column" (as opposed to vector?), if so,
matrix(unlist(temp,use.names=FALSE))
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list