/
server.R
30 lines (26 loc) · 1.01 KB
/
server.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
library(shiny)
library(chorddiag)
m <- matrix(c(11975, 5871, 8916, 2868,
1951, 10048, 2060, 6171,
8010, 16145, 8090, 8045,
1013, 990, 940, 6907),
byrow = TRUE,
nrow = 4, ncol = 4)
groupNames <- c("black", "blonde", "brown", "red")
groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")
row.names(m) <- groupNames
colnames(m) <- groupNames
shinyServer(function(input, output) {
output$chorddiag <- renderChorddiag(
chorddiag(m,
groupColors = groupColors,
groupnamePadding = input$groupnamePadding,
showTicks = input$showTicks,
margin = input$margin,
clickAction = "Shiny.onInputChange('sourceIndex', d.source.index+1);
Shiny.onInputChange('targetIndex', d.target.index+1);")
)
output$shiny_return <- renderPrint({
paste0(groupNames[input$sourceIndex], " <-> ", groupNames[input$targetIndex])
})
})