Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Viewing multiple objects using View function

Tags:

object

r

I have 10 objects eg1, eg2, eg3....eg10 that I want to see using the View() function in R. I have a feeling that I can write a simple code that would run View(egi) with i from 1 to 10, but I'm not sure how I could write this in R. Can anyone give me some advice?

like image 437
user3755880 Avatar asked Dec 17 '25 17:12

user3755880


1 Answers

I would suggest Map, like this:

eg1 <- eg2 <- eg3 <- data.frame(matrix(1:4, ncol = 2))
egs <- mget(ls(pattern = "^eg"))
Map(View, egs, names(egs))

Wrap it in invisible before running it if you don't want all those pesky NULLs in your console.

Proof :-)

enter image description here

like image 187
A5C1D2H2I1M1N2O1R2T1 Avatar answered Dec 20 '25 13:12

A5C1D2H2I1M1N2O1R2T1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!