简体   繁体   中英

Error in renderPlot (shiny)

I have a stange error in renderPlot section. Here is the example (extract from the main script):

ui.R

 splitLayout(cellWidths = 600, plotOutput("box_plot_best", width = "80%", height = "200px"))

server.r

output$box_plot_best <- renderPlot({

          boxplot(c(1:100), width=4, horizontal= TRUE, staplewex = 1, axes=FALSE, main=("Theoretical boxplot"))     
          abline(v = mean(c(1:100)), col = "red") 
          dev.off()

        })

Earlier everything was ok - the boxplot was generated. but now a strange error is generated:

Error in gregexpr(calltext, singleline, fixed = TRUE) :
regular expression is invalid UTF-8
Browse[2]> c
Warning: Error in grDevices::recordPlot: no current device to record from
Stack trace (innermost first):
89:
78: plotObj
77: origRenderFunc
76: output$box_plot_abs
1: runApp
Called from: eval(expr, envir, enclos)
Error in gregexpr(calltext, singleline, fixed = TRUE) :
regular expression is invalid UTF-8

I have found a similar error and solution but not exectly my case I would be gratefull for your hints.

It appears that the issue is with the dev.off() line. Once you remove that it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM