* Pandoc Error with Rmarkdown and Shiny @ 2017-08-25 8:24 Andrew Scotchmer [not found] ` <1c67925b-ebef-4e18-ba6d-477292e07160-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 2+ messages in thread From: Andrew Scotchmer @ 2017-08-25 8:24 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 2452 bytes --] Hi I have a simple R shiny app. Whenever I try and download the table I created I get the following error: pandoc: Cannot decode byte '\xfe': Data.Text.Internal.Encoding.Fusion.streamUtf8: Invalid UTF-8 stream Warning: Error in : pandoc document conversion failed with error 1 Stack trace (innermost first): 53: pandoc_convert 52: convert 51: rmarkdown::render 50: download$func [/home/scotcan1/Webshot/app.R#50] 1: shiny::runApp Error : pandoc document conversion failed with error 1 I don't know what this means. Here is my R/Shiny script and Rmarkdown. *R:* library(shiny) library(DT) data(iris) ui <- fluidPage( titlePanel("|Species Table"), sidebarLayout( sidebarPanel( selectInput("specs", "Number of bins:", unique(iris$Species)), downloadButton("download", "Download Report") ), mainPanel( tableOutput("specTable") ) ) ) server <- function(input, output) { subSpec <- function(x){ testdat <- iris[iris$Species == x, ] return(testdat[1:10,]) } reactiveFunction <- reactive({ subSpec(input$specs) }) output$reactiveTable <- renderDataTable({ reactiveFunction() }, rownames = FALSE) output$specTable <- renderUI({ dataTableOutput("reactiveTable") }) output$download <- downloadHandler( filename <- "report_file.html", content <- function(file){ write.csv(reactiveFunction(), "test_csv.csv", row.names = FALSE) params <- list(data = reactiveFunction()) rmarkdown::render(filename, output_file = file) } ) } shinyApp(ui = ui, server = server) *Rmarkdown:* --- title: "Untitled" output: html_document params: data: NA --- ```{r, echo=FALSE} data(iris) library(DT) datatable(params$data) ``` Any help to interpret the error appreciated. Andrew -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/1c67925b-ebef-4e18-ba6d-477292e07160%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 19648 bytes --] ^ permalink raw reply [flat|nested] 2+ messages in thread
[parent not found: <1c67925b-ebef-4e18-ba6d-477292e07160-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Pandoc Error with Rmarkdown and Shiny [not found] ` <1c67925b-ebef-4e18-ba6d-477292e07160-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2017-08-25 14:15 ` John MacFarlane 0 siblings, 0 replies; 2+ messages in thread From: John MacFarlane @ 2017-08-25 14:15 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw Pandoc expects its input to be UTF-8 encoded text, and complains in this way if it is not. Probably your script is using a different text encoding for the downloaded report_file.html. (Or, if this is downloaded, perhaps it's not UTF-8 encoded on the server.) You need to make sure it's UTF-8 encoded before passing it to pandoc or rmarkdown::render. (I speak without knowing what rmarkdown::render does, but I assume it just calls pandoc and doesn't do any encoding.) +++ Andrew Scotchmer [Aug 25 17 01:24 ]: > Hi > I have a simple R shiny app. Whenever I try and download the table I > created I get the following error: > pandoc: Cannot decode byte '\xfe': > Data.Text.Internal.Encoding.Fusion.streamUtf8: Invalid UTF-8 stream > Warning: Error in : pandoc document conversion failed with error 1 > Stack trace (innermost first): > 53: pandoc_convert > 52: convert > 51: rmarkdown::render > 50: download$func [/home/scotcan1/Webshot/app.R#50] > 1: shiny::runApp > Error : pandoc document conversion failed with error 1 > I don't know what this means. Here is my R/Shiny script and > Rmarkdown. > R: > library(shiny) > library(DT) > data(iris) > ui <- fluidPage( > > titlePanel("|Species Table"), > > sidebarLayout( > sidebarPanel( > selectInput("specs", > "Number of bins:", > unique(iris$Species)), > downloadButton("download", "Download Report") > ), > > mainPanel( > tableOutput("specTable") > ) > > ) > > ) > server <- function(input, output) { > > subSpec <- function(x){ > testdat <- iris[iris$Species == x, ] > return(testdat[1:10,]) > } > > reactiveFunction <- reactive({ subSpec(input$specs) }) > > > output$reactiveTable <- renderDataTable({ reactiveFunction() }, > rownames = FALSE) > > output$specTable <- renderUI({ > dataTableOutput("reactiveTable") > > }) > > > > output$download <- downloadHandler( > filename <- "report_file.html", > > content <- function(file){ > write.csv(reactiveFunction(), "test_csv.csv", row.names = FALSE) > params <- list(data = reactiveFunction()) > rmarkdown::render(filename, output_file = file) > } > ) > } > shinyApp(ui = ui, server = server) > Rmarkdown: > --- > title: "Untitled" > output: html_document > params: > data: NA > --- > ```{r, echo=FALSE} > data(iris) > library(DT) > datatable(params$data) > ``` > Any help to interpret the error appreciated. > Andrew > > -- > You received this message because you are subscribed to the Google > Groups "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to > [2]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > [3]https://groups.google.com/d/msgid/pandoc-discuss/1c67925b-ebef-4e18- > ba6d-477292e07160%40googlegroups.com. > For more options, visit [4]https://groups.google.com/d/optout. > >References > > 1. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > 2. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > 3. https://groups.google.com/d/msgid/pandoc-discuss/1c67925b-ebef-4e18-ba6d-477292e07160-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer > 4. https://groups.google.com/d/optout ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-25 14:15 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-08-25 8:24 Pandoc Error with Rmarkdown and Shiny Andrew Scotchmer [not found] ` <1c67925b-ebef-4e18-ba6d-477292e07160-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2017-08-25 14:15 ` John MacFarlane
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).