-
Notifications
You must be signed in to change notification settings - Fork 124
/
example_shiny.R
70 lines (51 loc) · 1.18 KB
/
example_shiny.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
62
63
64
65
66
67
68
69
70
\dontrun{
library(shiny)
library(sunburstR)
sequences <- read.csv(
system.file("examples/visit-sequences.csv",package="sunburstR")
,header=F
,stringsAsFactors = FALSE
)
server <- function(input,output,session){
output$sunburst <- renderSunburst({
#invalidateLater(1000, session)
sequences <- sequences[sample(nrow(sequences),1000),]
add_shiny(sunburst(sequences))
})
selection <- reactive({
input$sunburst_mouseover
})
output$selection <- renderText(selection())
}
ui<-fluidPage(
sidebarLayout(
sidebarPanel(
),
# plot sunburst
mainPanel(
sunburstOutput("sunburst"),
textOutput("selection")
)
)
)
shinyApp(ui = ui, server = server)
# an example with d2b sunburst and Shiny
library(shiny)
library(sunburstR)
# use a sample of the sequences csv data
sequences <- read.csv(
system.file("examples/visit-sequences.csv",package="sunburstR")
,header = FALSE
,stringsAsFactors = FALSE
)[1:200,]
# create a d2b sunburst
s2b <- sund2b(sequences)
options(shiny.trace=TRUE)
ui <- sund2bOutput("s2b")
server <- function(input, output, session) {
output$s2b <- renderSund2b({
add_shiny(s2b)
})
}
shinyApp(ui, server)
}