Home > Blockchain >  summary dataframe with loop in R
summary dataframe with loop in R

Time:10-19

I have three dataframe: AAA, BBB, CCC I want to use see summary of each dataframe, instead of using

summary(AAA)
summary(BBB)
summary(CCC)

I wonder if I can use loop to solve this function, I tried the following lines, but didn' work

tables = list('AAA', 'BBB', 'CCC')
for (table in tables){
  summary(table)
}

CodePudding user response:

You do not need a for loop necessarily, e.g.

tables = list(mtcars, mtcars)
purrr::map(tables, summary)

lapply(tables, summary)
  • Related