Reputation: 605
I have a matrix, a vector, an integer, and another list. These values change every time. I want to store these as individual rows (or of some sort) in a data structure.
The first value would be,
p <- c(1, 3, 4)
q <- matrix(c(1, 2, 4, 5), nrow=2, ncol=2)
r <- 8745
The second value would be
p <- c(1, 4, 4)
q <- matrix(c(5, 5, 4, 6), nrow=2, ncol=2)
r <- 8745454
And the third values,
p <- c(2, 5, 4)
q <- matrix(c(1, 3, 3, 6), nrow=2, ncol=2)
r <- 87
and so on
The ideal output is,
> Map(rbind, something) #if I do rbind
[[1]]
[,1] [,2] [,3]
[1,] 1 3 4
[2,] 1 4 4
[3,] 2 5 4
[[2]] (same matrix update here)
[,1] [,2]
[1,] 5 5
[2,] 5 5
[[3]]
[,1]
[1,] 8745
[2,] 8745454
[3,] 87
Upvotes: 0
Views: 57
Reputation: 605
I used the following to get this working,
Somelist <- list()
Somelist[[length(Somelist)+1]] <- list(p, q, r)
Upvotes: 1