# Matrix elements are vectors

4 messages
Open this post in threaded view
|

## Matrix elements are vectors

 Dear all, My question how is it possible to define a matrix A with 10 rows 1 column, so that its elements are vectors of undefined length. I need to have a possibility later to add elements like A[1,1] <- c(A[1,1],3,4,5) Thanks a lot for the help!         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Matrix elements are vectors

 On 05/04/2010 3:20 PM, Trafim Vanishek wrote: > Dear all, > > My question how is it possible to define a matrix A with 10 rows 1 column, > so that its elements are vectors of undefined length. > > I need to have a possibility later to add elements like A[1,1] <- > c(A[1,1],3,4,5) > > Thanks a lot for the help! You create the matrix from a list: A <- matrix( as.list(1:10), 10, 1) But now you need to be careful:  This won't work A[1,1] <- c(A[1,1],3,4,5) you need A[[1,1]] <- c(A[[1,1]],3,4,5) Duncan Murdoch ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.