Created
November 18, 2015 00:18
-
-
Save kissmygritts/ed565f622318d21a5932 to your computer and use it in GitHub Desktop.
Shiny server.R to use a text input as a list to remove/select particular records.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(ggplot2) | |
library(dplyr) | |
source("helpers.R") | |
shinyServer(function(input, output) { | |
#READS INPUT FROM FILE | |
inputdata <- reactive({ | |
if(is.null(input$file)) {return()} | |
read.csv(input$file$datapath, header = T, sep = ",", strip.white = T) | |
}) | |
#CREATES NUMERIC VECTOR TO REMOVE RECORDS FROM THE DATAFRAME | |
l1 <- reactive({ | |
remvtr <- strsplit(input$RemoveList, ", ") | |
remvtr <- remvtr[[1]] | |
remvtr <- as.numeric(remvtr) | |
return(remvtr) | |
}) | |
#CREATES DATAFRAME TO USE FOR THE PLOT AND TABLE | |
datasubset <- reactive({ | |
if (is.null(input$file)) {return()} | |
df.ranges <- pcrelisaConcat(inputdata()) | |
filterDF(df.ranges, input$SelectRange) | |
}) | |
#SUBSETS THE DATAFRAME TO REMOVE ROWS IN l1 | |
df <- reactive({ | |
if(input$RemoveList == "Remove Records" | input$RemoveList == "") { | |
return(datasubset()) | |
} else { | |
if(is.numeric(l1())) { | |
subset <- datasubset()[-l1(),] | |
return(subset) | |
} | |
} | |
}) | |
#PLOT: GENERATES THE PLOT OF THE MOUNTAIN RANGE > INPUT = df() | |
output$Barchart <- renderPlot({ | |
if (is.null(input$file)) {return()} | |
df.plot(df(), "PCR.ELISA", "PCR.ELISA") | |
}) | |
#TABLE: GENERATES TABLE OF RECORDS IN THE PLOT > INPUT = df() | |
output$Dataframe <- renderTable({ | |
if (is.null(input$file)) {return()} | |
df() | |
}) | |
#RANGE COUNT | |
output$RangeTable <- renderTable({ | |
if (is.null(input$file)) {return()} | |
df.group <- pcrelisaConcat(inputdata()) | |
df.range <- rangeFreq(df.group) | |
df.range | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment