Skip to content

Instantly share code, notes, and snippets.

@ajithbh
Last active November 14, 2017 09:07
Show Gist options
  • Save ajithbh/7c9e655782c0716f2c09ea69ef693b04 to your computer and use it in GitHub Desktop.
Save ajithbh/7c9e655782c0716f2c09ea69ef693b04 to your computer and use it in GitHub Desktop.
Plot dmeminfo trace using Shiny
# 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