server.R 1.92 KB
Newer Older
Stephanie's avatar
Stephanie committed
1 2 3 4 5 6 7 8 9 10
#
# This is the server logic of a Shiny web application. You can run the 
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
# 
#    http://shiny.rstudio.com/
#

library(shiny)
11
library(jsonlite)
12
library(DT)
Stephanie's avatar
Stephanie committed
13

Stephanie's avatar
Stephanie committed
14 15
server <- function(input, output) {
  set.seed(122)
16 17
  
  output$file1 <- renderDataTable({
18 19 20
    inFile <- input$file1
    if (is.null(inFile))
      return(NULL)
21
    
22 23
    json_data_coco <- fromJSON(paste(inFile$datapath, sep = ""), flatten = TRUE)
    coconut.df <- json_data_coco[["data"]]
24
    
25 26 27 28 29 30 31 32 33 34 35 36 37 38
    datatable(
              cbind(coconut.df), 
              options = list(
                searching = TRUE,
                autoWidth = TRUE,
                rownames = FALSE,
                scroller = TRUE,
                scrollX = TRUE,
                scrollY = "500px",
                fixedHeader = TRUE,
                class = 'cell-border stripe'
              )
    )
  
39 40 41
    #coconut.df$timestamp <- anytime((as.numeric(coconut.df$timestamp)/1000))
  })
  
42 43
  
  #TODO: CoCoQuest Output --> Ansätze data[] raus nehmen oder flatten richtig funken
44 45
  output$file2 <- renderDataTable({
    inFile <- input$file2
46 47
    if (is.null(inFile))
      return(NULL)
48
    
49 50 51 52 53
    json_data_quest <- fromJSON(paste(inFile$datapath, sep = ""), simplifyVector = TRUE, simplifyDataFrame = simplifyVector,
                                simplifyMatrix = simplifyVector, flatten = FALSE) 
    #flatten(json_data_quest)
    #json_data <-map() <-- ansatz zum parsen?
    
54 55 56 57 58 59 60 61 62
    
  })
  
  #data<-reactive({
  #file1 <- input$file1
  #if(is.null(file1)){return()}
  #read_json(file1=file1$datapath)
  #})
  
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
  #histdata <- rnorm(500)
  
  #output$plot1 <- renderPlot({
  #data <- histdata[seq_len(input$slider)]
  #hist(data)
  #})
  
  ##MAP 
  
  #m <- leaflet()
  #m <- addTiles(m)
  #x=1
  #for(x in 1:2019){
  #m <- addMarkers(m,lng=longitude[x], lat=latitude[x]) #addPolylines does not work
  #x=x+1}
  #m
  #}
Stephanie's avatar
Stephanie committed
80
}