public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Pandoc Error with Rmarkdown and Shiny
Date: Fri, 25 Aug 2017 07:15:08 -0700	[thread overview]
Message-ID: <20170825141508.GA26975@Johns-MacBook-Pro.local> (raw)
In-Reply-To: <1c67925b-ebef-4e18-ba6d-477292e07160-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

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


      parent reply	other threads:[~2017-08-25 14:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25  8:24 Andrew Scotchmer
     [not found] ` <1c67925b-ebef-4e18-ba6d-477292e07160-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-08-25 14:15   ` John MacFarlane [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170825141508.GA26975@Johns-MacBook-Pro.local \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).