Error while while knit in a OneDrive synced folder

The script below throws an error (see below) if knitted (both normal and notebook files) but only if the file is synced in OneDrive. If I put the file in the desktop, no error is given.

My default RStudio encoding is UTF-8.

My locale is > >"LC_COLLATE=Italian_Italy.1252;LC_CTYPE=Italian_Italy.1252;LC_MONETARY=Italian_Italy.1252;L>C_NUMERIC=C;LC_TIME=Italian_Italy.1252"

library(arsenal)
mycontrols  <- tableby.control(test=TRUE, total=F,
                               numeric.test="kwt", cat.test="fe",
                               numeric.stats=c("N","range", "medianq1q3",
                                               "meansd", "Nmiss"),
                               cat.stats=c("countpct"),
                               stats.labels=list(N='Count', median='Median', q1q3='Q1,Q3',mean='Mean', meansd="Mean (SD)"),
                               digits=1)

tab.test <- tableby( carb ~ .,
                     data= mtcars, 
                     control=mycontrols)
summary(tab.test, text = T)

Traceback:

BlockquoteError in gsub(""", "\"", string, fixed = TRUE) : input string 2 is invalid UTF-8
13.gsub(""", "\"", string, fixed = TRUE)
12.paste0(""", gsub(""", "\"", string, fixed = TRUE), """)
11.shQuote(args[shell_chars])
10.quoted(args)
9.paste(quoted(args), collapse = " ")
8.paste(quoted(pandoc()), paste(quoted(args), collapse = " "))
7.rmarkdown::pandoc_convert(input = rmarkdown::pandoc_path_arg(mdfile), to = "html", output = >rmarkdown::pandoc_path_arg(htmlfile))
6.print.knit_asis(knitr::asis_output(x))
5.print(knitr::asis_output(x))
4.print.knitr_kable(knitr::kable(df[[i]], caption = NULL, align = attr(df[[i]], "align"), format = format, >row.names = FALSE, escape = escape, ...))
3.print(knitr::kable(df[[i]], caption = NULL, align = attr(df[[i]], "align"), format = format, row.names = >FALSE, escape = escape, ...))
2.print.summary.arsenal_table(x)
1.(function (x, ...) UseMethod("print"))(x)

Hi @lucavd and welcome.

This is a strange error to get with this code.

I copied your code into an RMarkdown file and was able to knit it to HTML just fine. The same result when I saved it to my OneDrive folder and synced it.

Can you be sure that you are running only this code that you have included in your post? is there any other context? What does your whole file look like?

I have a different locale to you but am also using UTF-8.

@francisbarton, I have had similar problems when trying to use RMarkdown with files synced through OneDrive, though I don't have a reproducible example handy. My issue seemed to be solved (maybe) by upgrading to the current version of OneDrive, but I'm now having a strange problem with knitr::include_graphics() not being able to find the image file I'm trying to use, despite my using the full path name. I think this might be related the OneDrive problem (which is how I found this forum discussion), but I'm not sure yet. In any case, I'm certain that my original problem, from a year ago or so, was caused by OneDrive.

If you are still getting this error with knitr::include_graphics() then please start a new thread on this forum, with full details of the error message etc.

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