Last active
November 14, 2017 09:07
-
-
Save ajithbh/7c9e655782c0716f2c09ea69ef693b04 to your computer and use it in GitHub Desktop.
Plot dmeminfo trace using Shiny
This file contains 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
# Plot the meminfo graph | |
library(shiny) | |
options(shiny.maxRequestSize=30*1024^2) | |
# Define UI | |
ui <- fluidPage( | |
# Application title | |
titlePanel("Plot meminfo Time Series Data"), | |
sidebarLayout( | |
sidebarPanel( | |
fileInput("file1", | |
"Select CSV file", | |
accept = c( | |
"text/csv", | |
"text/comma-separated-values,text/plain", | |
".csv") | |
), | |
tags$hr(), | |
checkboxInput("header", "File Has Header: ", TRUE), | |
textInput("skip", "Number of lines to skip: ", value = 0), | |
tags$hr(), | |
sliderInput("samples", | |
"Number of samples per min:", | |
min = 1, | |
max = 60, | |
value = 60), | |
tags$hr(), | |
uiOutput("start"), | |
uiOutput("colSelect") | |
), | |
mainPanel( | |
plotOutput("timePlot") | |
) | |
) | |
) | |
# Define server logic required to draw the line graph | |
server <- function(input, output) { | |
observe({ | |
req(input$file1) | |
data <- read.csv(input$file1$datapath, header = input$header, skip = input$skip, as.is = TRUE) | |
selRows <- 60 / input$samples | |
output$colSelect <- renderUI({ | |
colNames <- names(data) | |
#colNames <- colNames[-1] | |
selectInput("colSel", "Choose Column", colNames, selected = "MemFree") | |
}) | |
output$timePlot <- renderPlot({ | |
data.new <- data[seq(1, nrow(data), selRows), ] | |
plot(data.new[,input$colSel], ylab = names(data.new[input$colSel]), type = "l") | |
}) | |
}) | |
} | |
# Run the application | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment