简体   繁体   中英

How to call environment objects from names in vectors

There are the names of the objects (data_frames) in the specified environment.

ls()
[1] "a"         "b"

I have assigned the names of the objects to a vector, eg n_obj <- c('a', 'b')

How to call my objects using the vector of the names n_obj ? n_obj[1] return logical a string 'a', but I need to run 'a' as my saved dataframe 'a' in the environment.

I'd use the get function

get(n_obj[1])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM