Reputation: 345
This prints as a regular code but not at all using rmarkdown. The problem may be located in the condensed and styling options of the code.. Any thoughts?
{r printing,echo=FALSE, cache=FALSE, results='asis'}
library(tidyverse)
library(kableExtra)
library(dotwhisker)
library(broom)
kbl <- function (df) {
cat("\n\n")
df2<-kable(df) %>% kable_styling(bootstrap_options = c("striped", "condensed"))
print(df2)
cat("\n\n")
}
df <- mtcars
nested_inter <- mtcars %>% group_by(gear) %>%
nest() ## groups all the data by the sub series
nested_inter <- nested_inter %>%
mutate (model = map(data,
~lm(formula = mpg ~ cyl + drat + hp +wt , data = .)))
for(i in seq(nrow(nested_inter))) {
kbl(glance(nested_inter$model[[i]]))
t1<- nested_inter$model[[i]] %>% broom::tidy()
kbl(t1)
}
Thanks!
Upvotes: 0
Views: 515
Reputation: 3242
Is this more of what you were looking for? Your code example didn't have the proper Rmarkdown syntax.
---
title: "Kable output"
output: html_document
---
```{r printing,echo=FALSE, message = FALSE, warning = FALSE,cache=FALSE, results='asis'}
library(tidyverse)
library(kableExtra)
library(dotwhisker)
library(broom)
kbl <- function (df) {
cat("\n\n")
df2<-kable(df) %>% kable_styling(bootstrap_options = c("striped", "condensed"))
print(df2)
cat("\n\n")
}
df <- mtcars
nested_inter <- mtcars %>% group_by(gear) %>%
nest() ## groups all the data by the sub series
nested_inter <- nested_inter %>%
mutate (model = map(data,
~lm(formula = mpg ~ cyl + drat + hp +wt , data = .)))
for(i in seq(nrow(nested_inter))) {
kbl(glance(nested_inter$model[[i]]))
t1<- nested_inter$model[[i]] %>% broom::tidy()
kbl(t1)
}
```
Upvotes: 1