```
 m <- matrix(1:4, ncol=2)
 l <- list(a=1:3, b='c')
 d <- data.frame(a=1:3, b=3:1)

```

I was wondering if it is possible to make a function that takes a base R object (matrix, vector, list or data.frame, ...) as well as a text that specifies the subset of the object.

```
f1 <- function(object, subset) {
    # object'subset' 
  }

```

For instance 

```
f1(m, '[1,1]') #to evaluate m[1,1]
f1(l, '[[1]][2:3]') #l[[1]][2:3]
f1(d, '$a') #d$a

```

would give us (respectively):

```
[1] 1
[1] 2 3
[1] 1 2 3

```

I guess the function need somehow to glue the two arguments before evaluating. I guess one could make a kind of interpreter for each bit of the subset text and the (for the matrix example) do something like:

```
`[`(1,1)

```

This would possible but I thought there would be an easier more direct way (my 'glue' above).