-
Notifications
You must be signed in to change notification settings - Fork 17
/
global.R
61 lines (56 loc) · 1.46 KB
/
global.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
library(dplyr)
library(shiny)
library(knitr)
library(DT)
library(ggplot2)
library(htmltools)
library(htmlwidgets)
# original -- devtools::install_github("timelyportfolio/functionplotR@139a2bcaea6a2f10c181473efb2bd29b7418b4bb")
# fixed for shinyapps.io -- devtools::install_github("vnijs/functionplotR")
library(functionplotR)
encoding <- getOption("shiny.site.encoding", default = "UTF-8")
## options for knitting/rendering rmarkdown chunks
knitr::opts_chunk$set(
echo = FALSE,
comment = NA,
cache = FALSE,
message = FALSE,
warning = FALSE
)
## function to render .md files to html
inclMD <- function(path) {
markdown::markdownToHTML(
path,
fragment.only = TRUE,
options = "",
stylesheet = "",
encoding = encoding
)
}
## function to render .Rmd files to html - does not embed image or add css
inclRmd <- function(path, r_env = parent.frame()) {
paste(
readLines(path, warn = FALSE, encoding = encoding),
collapse = '\n'
) %>%
knitr::knit2html(
text = .,
fragment.only = TRUE,
envir = r_env,
options = "",
stylesheet = "",
encoding = encoding
) %>%
gsub("<!--/html_preserve-->","",.) %>% ## knitr adds this
gsub("<!--html_preserve-->","",.) %>% ## knitr adds this
HTML
}
## make html table
make_table <- function(dat, width = "50%") {
knitr::kable(
dat,
align = "c",
format = "html",
table.attr = paste0("class='table table-condensed table-hover' style='width:", width, ";'")
)
}