Home > Net >  Display multiple calculated values in a table - R
Display multiple calculated values in a table - R

Time:10-21

I have the following calculated values stored in seven different variables. Now I want them to display in an R output as follows. How I can achieve this? (The following table was created with markdown) assigning values to the data frame and printing it does not give my intended results. I am looking for more "cleaner" table.

mean_reg standard_deviation minimum First_quartile median third_quartile maximum iq_range
31.10846 7.996179 2.5 27.92578 29.73158 33.85013 55.5 5.92435

CodePudding user response:

With data.frame:

mean_reg <- 31.10846
standard_deviation <- 7.996179
minimum <- 2.5
First_quartile <- 27.92578
median <- 29.73158
third_quartile <- 33.85013
maximum <- 55.5
iq_range <- 5.92435

df <- data.frame(mean_reg,standard_deviation,minimum,First_quartile,median,third_quartile,maximum,iq_range)

output:

> df
  mean_reg standard_deviation minimum First_quartile   median third_quartile maximum iq_range
1 31.10846           7.996179     2.5       27.92578 29.73158       33.85013    55.5  5.92435

CodePudding user response:

Thanks All for the comments. I found that "kableExtra" package can be used to get a cleaner result as i intended.

mean_reg <- 31.10846
standard_deviation <- 7.996179
minimum <- 2.5
First_quartile <- 27.92578
median <- 29.73158
third_quartile <- 33.85013
maximum <- 55.5
iq_range <- 5.92435

    df <- data.frame(mean_reg,standard_deviation,minimum,First_quartile,median,third_quartile,maximum,iq_range) %>% kbl() %>% kable_classic(full_width = F, html_font = "Cambria")
  •  Tags:  
  • r
  • Related