0
library(shiny)
library(plotly)
library(dplyr)
library(scales)
library(reticulate)
source_python("cems_api.py")

ui <- fluidPage(
  plotlyOutput("plot")
)

server <- function(input, output) {

  # renderPlotly() also understands ggplot2 objects!
  output$plot <- renderPlotly({
    SO_table$polno <- as.factor(unlist(SO_table$polno))
    SO_table$m_time <- as.POSIXct(SO_table$m_time, format="%Y/%m/%d %H:%M")
    SO_ggplot<- SO_table %>% ggplot(aes(x = m_time, y = m_val, color=polno)) + 
      geom_point() +
      geom_line()+
      theme_bw()+
      labs(y="ppm")+
      scale_x_datetime(date_labels="%m/%d %H:%M:%S")
    SO_linechart <- ggplotly(SO_ggplot)
  })

}

shinyApp(ui, server)

Hello, everyone. There is a big problem in the code which I can't handle. It shows that:

Warning: Error in isReallyReal: x must be of type double.

But I have set and checked class and typeof are the same as the dataset in the example. So, I don't know how to solve it. Can someone teach me?

Here are my code and file needed. https://drive.google.com/open?id=12JPV9AaLfoCBb_VsFJOiDowdQHwOu_Qy

Wilmar van Ommeren
  • 7,469
  • 6
  • 34
  • 65
Karen
  • 7
  • 5
  • Can you also include `cems_api.py` in the google-drive file or is it not necessary for this example? – SeGa Dec 03 '18 at 13:30
  • Hello, SeGa. Sorry for that I can't provide cems_api.py for you because the file connects to database. But there is a file called SO_table.csv thar contains all data needed for the plotly and the column names are the same as typed in the previous code. – Karen Dec 05 '18 at 08:26
  • Well I suspect the error comes from this function `instant_24`, since your App runs if you omit those 2 lines. Maybe you can share that function? – SeGa Dec 05 '18 at 09:20
  • Well, the lines "SO_table <- instant_24("E5600056") %>% subset(item == '922') NO_table <- instant_24("E5600056") %>% subset(item == '923')" can be replaced with SO_table <- read_table("SO_table.csv", header = TRUE, sep = ","). So, the instant_24 will not influence the program. – Karen Dec 08 '18 at 06:40

0 Answers0