I'm trying to develop a dashboard using R Shiny which extract data from a MySQL database and represents it in graphical form. I need to create a time series using several data. But a problem occurs when the time stamp values in MySQL cannot be converted in to date time values in the time series. Following is my server.R
code:
con <- dbConnect(MySQL(),user="root",password="891208",host="localhost",dbname="openPos")
shinyServer(function(input, output) {
query1 <- reactive({ "SELECT sale_time,sum(quantity_purchased * item_unit_price)
AS revenue, sum(quantity_purchased * item_cost_price) AS cost,
sum(quantity_purchased * item_unit_price)-sum(quantity_purchased * item_cost_price) as profit
FROM ospos_sales, ospos_sales_items
WHERE ospos_sales.sale_id = ospos_sales_items.sale_id
GROUP BY sale_time"})
result1 <- reactive({dbGetQuery(con,query1())})
z <- reactive({ts(result1())})
output$ts <- renderPlot({p<-ts.plot(z())
print(p)})
output$table <-renderTable({z()})
The output of the table will look like this
Can anyone please tell me why I can't create a time series with these database values?