r-glue

How can I make a collapse with glue package using RMarkdown?

别等时光非礼了梦想. 提交于 2020-07-16 07:00:52
问题 I've been trying to automate the results of some df table in latex using the glue and stargazer packages, but I haven't had any results (what I want is for the meaning "^{*}" to appear next to each value as it is in the table) to use then RMarkdown. What I want to get: My current ugly and error-prone fix: library(dplyr) library(glue) library(stargazer) X1 = c(4.70e1, 4.72e1, 4.76e1, 2.73e20) X2 = c(4.67e1, 4.69e1, 4.77e1, 2.05e20) tab.out = data.frame(X1, X2) tab.out$max<-apply(tab.out, 1,

Get level names using glue and dplyr in a loop

匆匆过客 提交于 2020-07-07 07:10:16
问题 I am trying to get level names from a table using dplyr and glue in a loop (I use a loop because I get a large number of variable to get grouped tables and individual tables), I show an example below: library(dplyr) library(glue) var=c( "vs", "am") for(i in var) { bd=mtcars%>% group_by(carb) %>% count_(i) %>% mutate(descripcion = glue("carb number:{carb} in: {i} with freq: {n},")) print(bd) print(bd$descripcion) } my result: Groups: carb [6] carb vs n descripcion <dbl> <dbl> <int> <chr> 1 1 1

Using `ggplotly` and `DT` from a `for` loop in Rmarkdown

人盡茶涼 提交于 2020-06-27 04:03:11
问题 Is that possible to use ggplotly() or datatable() in RMarkdown from inside a for loop or function? Example: --- title: "Using `ggplotly` and `DT` from a `for` loop in Rmarkdown" output: html_document --- ```{r setup, include=FALSE} library(ggplot2); library(DT) ``` ## Without `for` loop - works ```{r} datatable(cars) g <- ggplot(cars) + geom_histogram(aes_string(x=names(cars)[1] )) ggplotly(g) ``` ## From inside the `for` loop - does not work (nothing is printed) ```{r} for( col in 1:ncol