Is R equivalent to MATLAB?

Is there an R type equivalent to a Matlab structure type?

I have several named vectors, and I'm trying to save them in a data frame. Ideally, I would simply access one element of the object and return the named vectors (for example, the structure in Matlab). I believe that using a data frame is wrong, because it can store the values โ€‹โ€‹of named vectors, but not names, when they differ from one vector to another.

More generally, is it possible to store a bunch of different objects in one in R?

Change . As Joran said, I think that listdoes the job.

l = list()
l$vec1 = namedVector1
l$vec2 = namedVector2
...

If I have a list of names

name1 = 'vec1'
name2 = 'vec2'

, , , 1, , ? get(name1), .

+5
1

, , , , :

l <- list(a= 1:3,b = 1:10)
> ind <- "a"
> l[[ind]]
[1] 1 2 3

, [[.

+5

All Articles