R Markdown Tables - getting started

Would anyone have a good resource handy for creating knitr kables using disparate data sources? I have a bunch of numbers from statistical analyses that I want to put into a table in my R markdown document, but I'm not sure of the best way to go about this. They are results from several statistical tests.

I apologize that this question is kind of vague, but this reflects my lack of knowledge of where to start. Help appreciated!

This doesnt seem like its actually an R markdown question, rather a data transformation question.
You are asking about how to construct a single data.frame from different sources.
This might involve joins, but more likely constructing columns or rows programatically.

library(tidyverse)

(mean_of_iris_setosa_petal_length_df  <- filter(iris,
                                                Species=="setosa")%>%
    summarise(mean_of_iris_setosa_petal_length =
                mean(Petal.Length)))

(max_miles_per_gallon_mpg_audi_df  <- filter(mpg,
                                                manufacturer=="audi")%>%
    summarise(max_miles_per_gallon_mpg_audi =
                max(hwy)))

(my_table <- tibble(mean_of_iris_setosa_petal_length_df,
                       max_miles_per_gallon_mpg_audi_df))

# A tibble: 1 x 2
mean_of_iris_setosa_petal_length max_miles_per_gallon_mpg_audi
<dbl>                         <int>
  1                             1.46                            31

Got it. I appreciate the example! Thanks much!

  • ice

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.