简体   繁体   中英

Calling multiple objects from one vector of names within an R function

I have several objects in my R environments that are named with the same prefix (for instance, 'test.'). Each object is the result of a model fitting. I want to automatize the comparison among models, by first, defining the vector of the names of such objects:

list_obj<-ls(pattern="test.")

And, then, put the list of objects within the R function that summarise the models and identify the best model among all 'test.' objects.

result<-summarize(list_obj)

However, this approach is not correct and does not work.

Do you have any suggestion?

获取列表中的模型并使用do.call

res <- do.call(summarize, mget(ls(pattern="test\\.")))

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