get() function in R

The get() function might be one of the most useful utilities in R. However I’ve never use this function before I write this page. Shame on me.

Well, let’s get to the point. The job of the get() function is actually quite simple: given the name of an object, it fetches the object itself. See the example below:

> x <- c(1:3)
> x
[1] 1 2 3
> get("x")
[1] 1 2 3

It’s easy to imagine how useful this function is.

 

Reference: The Art of R Programming by Norman Matloff

Posted in R Programming Tips and tagged .

Leave a Reply

Your email address will not be published. Required fields are marked *