问题
I'm trying to make a model for non parametric regression with Maximal Overlap Discrete Wavelet Transform (MODWT) using this data taken from here and here. The packages I'm using here are shiny
, wavelets
, and readxl
.
Here is my server code:
server <- function(input, output) {
dataset<-reactive({
inFile <- input$filewav
dat <- read_excel(inFile$datapath)
df <- data.frame(dat[,2], dat[,3])
x <- seq(1,nrow(df),length = nrow(df))
y <- df[,2]
return(dat)
})
output$plot_mra <- renderPlot({
filt <- switch(input$filterwav,
"Haar (d2)" = filter()$haar,
"d4" = filter()$d4,
"d6" = filter()$d6,
"d8" = filter()$d8,
"s4" = filter()$s4,
"s6" = filter()$s6,
"s8" = filter()$s8,
"c6" = filter()$c6,
"c12" = filter()$c12)
mra.y <- switch(input$reswav,
"1" = y.mra()@S$S1,
"2" = y.mra()@S$S2,
"3" = y.mra()@S$S3,
"4" = y.mra()@S$S4,
"5" = y.mra()@S$S5,
"6" = y.mra()@S$S6,
"7" = y.mra()@S$S7,
"8" = y.mra()@S$S8,
"9" = y.mra()@S$S9,
"10" = y.mra()@S$S10)
set.seed(2)
y.mra <- mra(y,filt,input$reswav,"periodic",TRUE,"modwt")
if(input$reswav==0)
{plot(x,y, ylab = "", type = "p", col = "red")
mtext("Fungsi Asli", side = 3, line = 0.1)}
else
{plot(x,y, ylab = "", type = "p", col = "red")
par(new = TRUE)
plot(x,mra.y, ylab = "y", xlab = "x", type = "l", col = "blue")
mtext("Hasil Analisis Multiresolusi dengan MODWT", side = 3, line = 0.1)}
})
}
And here is my UI code:
ui <- fluidPage(
titlePanel("Pemodelan Regresi dengan Metode Wavelet Linier"),
sidebarLayout(
sidebarPanel(
fileInput("filewav", "Masukkan data",
multiple = FALSE,
accept = c(".xls",".xlsx")),
selectInput("filterwav", "Pilih filter wavelet",
choices = list('Daublets' = c('Haar (d2)','d4','d6','d8'),
'Symmlets' = c('s4','s6','s8'),
'Coiflets' = c('c6','c12'))),
numericInput("reswav", "Masukkan nilai resolusi", 1, min = 0, max = 10, step = NA,
width = NULL),
helpText("Oleh: Sania Anisa Farah")),
mainPanel(
plotOutput("plot_mra"))
))
I tried to execute those codes with shinyApp(ui = ui, server = server)
and this is what I got:
Warning: Error in as.ts: argument "x" is missing, with no default
Stack trace (innermost first):
104: as.ts
103: filter
102: renderPlot [#12]
92: <reactive:plotObj>
81: plotObj
80: origRenderFunc
79: output$plot_mra
4: <Anonymous>
3: do.call
2: print.shiny.appobj
1: <Promise>
Yes, that output in the R console and this in the program itself. Can anybody please show me where I went wrong? And how am I supposed to fix it?
PS: please excuse my language, I'm using Bahasa Indonesia in my program above.
来源:https://stackoverflow.com/questions/49206529/r-shiny-error-argument-x-is-missing-with-no-default