get(x)
Call an R object using a character string.
- x – The name of an R object, listed as a character string.
Example. Some basic examples are shown below. Notice that only the object name may be called in the character string; subsetting or function arguments for the R object of interest should be placed outside of get.
> x5 <- "x5 variable" > get("x5") [1] "x5 variable" > > L3 <- list("list", "of", "three") > get("L3") [[1]] [1] "list" [[2]] [1] "of" [[3]] [1] "three" > > get("L3[[3]]") Error in get("L3[[3]]") : object 'L3[[3]]' not found > > get("L3")[[3]] [1] "three" > > get("mean")(c(1.5, 2.5, 3.5, 4.5)) [1] 3
No comments:
Post a Comment