I'm trying to plot my data from the sensor i choose in the SelectInput, so far i have no errors but also no plot.
So when someone visits the page, he can select a sensor en the data of that sensor will be plotted on the Y-axis and the timestamp on the X-axis.
I already asked the question but i'm still stuck at the same point. Did alot of research online but I can't seem to find the answer.
Here is my code
Server.R
library(shiny)
library(RMySQL)
options(mysql = list(
"host" = "185.56.135.42",
"port" = 3306,
"user" = "xxx",
"password" = "xxx"
))
databaseName <- "pxleai1q_1305141"
table <- "sensorParser"
shinyServer(function(input, output) {
loadData <- eventReactive(input$doQuery, {
# Connect to the database
db <- dbConnect(MySQL(), dbname = databaseName, host = options()$mysql$host,
port = options()$mysql$port, user = options()$mysql$user,
password = options()$mysql$password)
# Construct the fetching query
query <- sprintf("SELECT Value FROM %s where sensor = '%s'", table, input$sensor)
# Submit the fetch query and disconnect
data <- dbGetQuery(db, query)
dbDisconnect(db)
data;
})
# output$plot <- renderPlot({plot(fsrData$timestamp ~ fsrData$value, fsrData = loadData())})
output$plot <- renderPlot({plot(timestamp ~ value, data = loadData())})
output$text1 <- renderText({
paste("dump: ", input$sensor)
})
})
ui.R
library(shiny)
library(RMySQL)
shinyUI(fluidPage(
# Application title
titlePanel("Visualisatie gegevens"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel("hier ziet u de visualisatie van de gegevens",
selectInput("sensor",
label = "choose a variable to display",
choices = list("FSR", "HumSensor", "TempSensor","BPMSensor")),
actionButton("doQuery", label = "weergave")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("Plot"),
textOutput("text1")
)
)
))
this is de database I'm trying to read
id id_wasp id_secret frame_type frame_number sensor value timestamp raw parser_type
1926 Waspmote 403476432 128 19 TIME 0522 20160316 12:06:51 noraw 0
1927 Waspmote 403476432 128 19 FSR 273 20160316 12:06:51 noraw 0
1928 Waspmote 403476432 128 19 HumSensor 130 20160316 12:06:51 noraw 0
1929 Waspmote 403476432 128 19 TempSensor0 0 20160316 12:06:51 noraw 0
1930 Waspmote 403476432 128 19 BPMSensor 0 20160316 12:06:51 noraw 0
1931 Waspmote 403476432 128 20 TIME 0529 20160316 12:06:58 noraw 0
1932 Waspmote 403476432 128 20 FSR 1023 20160316 12:06:58 noraw 0
1933 Waspmote 403476432 128 20 HumSensor 897 20160316 12:06:58 noraw 0
1934 Waspmote 403476432 128 20 TempSensor627 627 20160316 12:06:58 noraw 0
1935 Waspmote 403476432 128 20 BPMSensor 280 20160316 12:06:58 noraw 0
1936 Waspmote 403476432 128 21 TIME 0535 20160316 12:07:05 noraw 0