[Solved] how to create a dataframe in R from ” Min. 1stQu Median Mean 3rdQu Max. NA’s”? [closed]


One approach is to use the tidy function from the broom package. It is versatile and can organize most R statistical results into a data frame.

library(broom)
set.seed(1)
x <- rnorm(1000)
x[sample(1:length(x), 100)] <- NA
df <- tidy(summary(x))
df
  minimum      q1   median    mean     q3 maximum NA's
1  -3.008 -0.6834 -0.01371 0.00106 0.6978    3.81  100

As you can see, it is a data frame:

class(df)
[1] "data.frame"

3

solved how to create a dataframe in R from ” Min. 1stQu Median Mean 3rdQu Max. NA’s”? [closed]