About the data.frame to markdown table, here are some examples:
with knitr
subset_iris <- iris[1:5, ]
knitr::kable(subset_iris, format = "markdown")
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
cat(knitr::kable(subset_iris, format = "markdown"), sep = "\n")
#> | Sepal.Length| Sepal.Width| Petal.Length| Petal.Width|Species |
#> |------------:|-----------:|------------:|-----------:|:-------|
#> | 5.1| 3.5| 1.4| 0.2|setosa |
#> | 4.9| 3.0| 1.4| 0.2|setosa |
#> | 4.7| 3.2| 1.3| 0.2|setosa |
#> | 4.6| 3.1| 1.5| 0.2|setosa |
#> | 5.0| 3.6| 1.4| 0.2|setosa |
You also have {pander} which use pandoc markdown syntax but could also work
pander::pandoc.table(subset_iris)
#>
#> -------------------------------------------------------------------
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> -------------- ------------- -------------- ------------- ---------
#> 5.1 3.5 1.4 0.2 setosa
#>
#> 4.9 3 1.4 0.2 setosa
#>
#> 4.7 3.2 1.3 0.2 setosa
#>
#> 4.6 3.1 1.5 0.2 setosa
#>
#> 5 3.6 1.4 0.2 setosa
#> -------------------------------------------------------------------
that render in html as
pander::pandoc.table(subset_iris)
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5 | 3.6 | 1.4 | 0.2 | setosa |
Created on 2018-08-13 by the reprex package (v0.2.0).
You should look at the options of these two functions.