-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShinyAceMarkdown_InputRscript.R
More file actions
101 lines (72 loc) · 1.88 KB
/
ShinyAceMarkdown_InputRscript.R
File metadata and controls
101 lines (72 loc) · 1.88 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
library(shiny)
library(shinyAce)
library(shinydashboard)
library(knitr)
shinyApp(
shinyUI(
bootstrapPage(
fluidRow(
column(width = 2,
box(width = 12,
numericInput("num1", "Select rnorm number", value = 5, min = 1, max = 100),
selectInput("modular", "Select Modualr", choices = dir("Modulars", pattern = ".R"))
) # box
), # column
column(width = 5,
box(width = 12,
h2("Source R-Markdown"),
uiOutput("ace_ui"),
# aceEditor("rmd", mode = "markdown",
# value = '### Sample knitr Doc
#
# This is some markdown text. It may also have embedded R code
# which will be executed.
#
# ```{r}
# 2*3
# rnorm(5)
# ```
#
# It can even include graphical elements.
#
# ``{r}
# hist(rnorm(100))
# ```
#
# '),
actionButton("eval", "Update")
) # box
), # column
column(width = 5,
box(width = 12,
h2("Knitted Output"),
htmlOutput("knitDoc")
) # box
) # column
) # fluidRow
) # bootsrapPage
),
shinyServer(function(input, output, session) {
output$ace_ui <- renderUI({
num_inpt <- input$num1
val <- paste('### Sample knitr Doc
This is some markdown text. It may also have embedded R code
which will be executed.
```{r}
2*3
rnorm(', num_inpt, ')
```')
aceEditor("rmd", mode = "markdown", value = val)
})
output$knitDoc <- renderUI({
input$eval
return(
isolate(
HTML(
knit2html(text = input$rmd, fragment.only = TRUE, quiet = TRUE)
)
)
)
})
})
)