albert
albert

Reputation: 325

Vector of vectors in R but not is matrix

I have a little problem using vector of vector. In my routine R, : don't know how create and assign elements to a vector of vectors but not is a matrix Some columns or rows have more elements than others.Then be able to call one of the elements

for example the vector :

v=( c(1,2,3) , c(3,4,5,1,3,4,1,) , c(3,4) , c(3,3,3,3,3,1,2,) )

then, v[3] should show (3,4)

I tried a for for (i in 1:k){t[i] <- x[v[[j]](x) > w[j]]}

but is bad

Upvotes: 1

Views: 943

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521289

Use a list:

myList <- list(c(1,2,3), c(3,4,5,1,3,4,1,) , c(3,4), c(3,3,3,3,3,1,2,))

> myList[3] 
[[1]] 
[1] 3 4

Upvotes: 4

Related Questions