-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.R
34 lines (25 loc) · 1.04 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
31
32
33
34
library(shiny)
library(TSclust)
shinyServer(function(input, output) {
output$distPlot <- renderImage({
inFile <- input$file1
if (is.null(inFile)){
return (NULL)}
file<-read.csv(file = inFile$datapath, sep = input$sep, dec = input$dec)
clust<-diss(file, "CDM") # applying distance metrics
clust <- hclust(clust, method = "ward.D") # calculating distances
outfile <- tempfile(fileext='.png') # this format is better for this type of graphs
png(outfile, width=input$w, height=input$h) # and is ready to use in papers.
par(cex=1)
plot(clust, main=input$main, xlab = input$xlab, ylab = input$ylab, sub = "")
if (input$rect == TRUE) {
rect.hclust(clust, k=input$k, border = input$rectcol) # cluster highlighting
}
dev.off()
list(src = outfile,
contentType = 'image/png',
width = input$w,
height = input$h,
alt = "Please upload a file")
}, deleteFile = TRUE)
})