[R] vector entry in matix

R. Michael Weylandt
Thu, 05 Jul 2012 15:22:09 -0000

It is possible to put dimensionality on a list (i.e., a generic
vector), which might be what you're looking for.

x <- list(1:4, letters[1:4], function(x,y) x + y, rnorm(50))
dim(x) <- c(2,2)

x[[1,2]]

x[[2,2]]

x[[3,2]] # Error

Best,
Michael

On Thu, Jul 5, 2012 at 8:19 AM, Thomas C. <thomas.csapak at gmail.com>
wrote:
> hi,
>
> i'm trying to figure out if there's any possibility to write a
whole vector
> into a matrix or data.frame or something like that. i don't mean
> transormation. Here an example:
>
>        [,1]  [,2]
> [1,] "a" "d"
> [2,] "b" "e"
> [3,] "c" "f"
>
>
> where e.g.  a is a<-c(0,1) vector of length 2, b a vector of length
4,... (i
> know that the matrix enties are strings :)). i'm trying to put some
> variables into a matrix or data.frame, but i couldn't handle it. is
> something like that possible in R?
>
> thanks for your help!
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/vector-entry-in-matix-tp4635478.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.