error in my app.r

My app opens up but I get an error:Error in getDataset: could not find function "getDataset". I am new to Shiny so I am not sure what is up.

server <- (function(input, output) {
  getDatasett<-reactive({
    if(input$year=="2020")
    {
      return("df2020")
    }
    else if (input$year=="2019")
    {
      return("df2019")
    }
    else if (input$year=="2018")
    {
      return("df2018")
    }
    else
    {
      return("2017")
    }
  })
                     
  output$caption<-renderText({
    paste("Dataset: ", input$year)
  })
  output$ts_plot<-renderPlot(({
    ts_plot<-ts(getDataset(),aes(x="Closed",y=n,frequency=12))
    plot(ts_plot)
    })
  )
})

shinyApp(ui = ui, server = server)

extra t getDatasett

I love typos. Now I am getting non-numeric argument to binary operator

Well, your dataset isn't really a dataset, its some text, so I'm sure i don't know what's going on.
I recommend that you demo one state of your shiny app in a plain r script without shiny first before you then grow a shiny app out of it.

Hello, can you show your dataset?

I think I have the ingest of data figured out. Now I am having an issue what is probably stupid. I am getting an error with the beginning of my data carpentry

Error in ndl_data(var_one = c("2020", "2019", "2018", "2017"), var_two = c("SCI", :
could not find function "ndl_data"

ndl_data<-system.file("extdata", "C:\\Users\\yatestm\\documents\\Capstone\\Capstone\\Trial 6\\STEI Account Work", package="readxl")
a_df<-ndl_data(
  var_one=c("2020","2019","2018","2017"),
  var_two=c("SCI","SC","U")
)

I cannot show the actual data, but my data set only has 3 columns. The closed column is d/m/yyy
Short_Description, Closed, Network

ok I changed my script. I am trying to go piece by piece. Currently I have

library(shiny)
library(readxl)
library(plotly)
library(dplyr)
library(ggplot2)
library(forecast)
library(tidyverse)
library(lubridate)
library(zoo)

#read_excel(data)
data<-read_xlsx(".xlsx")

# convert the Closed column to an actual date so that we can easily select all days in a given year.
new.date.time<-as.POSIXct(data$Closed,format="%d/$m/$y")

# select everything by year
df$"2018" <- data[data$"Closed" >= "01/01/2018" & data$"Closed" <= "31/12/2018",]
df2018<-df$"2018"
df2018ts<-ts(df2018,frequency = 12,start("2018-01-01"))
df$"SCI" <- df2018[which(df2018$"Network"== "COE")]

I am having an issue with the last part

select everything by year

df$"2018" <- data[data$"Closed" >= "01/01/2018" & data$"Closed" <= "31/12/2018",]
Error in df$"2018" <- data[data$Closed >= "01/01/2018" & data$Closed <= :
object of type 'closure' is not subsettable

Its a bad idea to name your own objects with the names of existing R objects.
Both data and df fall into that camp.
Also I notice you are heavily leaning on base R rather than tidyverse/dplyr despite loading them. Applying a dplyr filter seems a lot more elegant to me than the base R subsetting syntax that involves repeating the dataframe name.

df$"colname" is not a good writing
Try df$colname.
dplyr is very good to manipulate data in table.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.