I have been running the following series of commands on sets of .csv files that I am loading into my workspace. Everything was working well, until I tried a new data set.
I keep receiving the error when I try and display the data in my Shiny App: Error in UseMethod("as.xts") : no applicable method for 'as.xts' applied to an object of class "NULL"
I receive no errors when completing the following commands:
Data1 <- read.csv("Data1.csv", stringsAsFactors = FALSE)
Data1$Time <- as.POSIXct(strptime(Data1$Time,"%m/%d/%Y %H:%M:%S" ))
Data1 <- xts(Data1[,-1], order.by=Data1[,1])
It's just weird that it was working for one .csv, and when I copied the same Time column from the first .csv to the new .csv, it doesn't load.
Update
Right now, every single input column is being graphed on my dygraph. I know that my issue is in the dygraph(dataSource(), main = "Data")
. I know that dataSource() is causing everything to be graphed. How to do I make it so that only the selected input is graphed?
My server.R
code is as follows:
dataSource1 <- reactive({
switch(input$dataSelection1,
"File1" = File1,
"File2" = File2,
"File3" = File3,
"File4" = File4,
"File5" = File5)
})
observeEvent(input$dataSelection1, {
updateSelectizeInput(session, 'component1', choices = names(dataSource1()))
})
output$TempRise <- renderDygraph({
dygraph(dataSource1(), main = "Data") %>%
dyRangeSelector() %>%
dyOptions(colors = RColorBrewer::brewer.pal(8, "Dark2"))
})
My ui.R
code is as follows:
sidebarPanel(
selectInput('dataSelection', 'DATASELECTION', choice = NULL),
selectInput("dataSelection1", label = "Choose a File",
choices = c("File1","File2", "File3","File4", "File5")),
selectInput("component1", label = "Choose a Second Component",
choices = NULL),
mainPanel(
dygraphOutput("Data"),