Ajax Error with RStudio DT DataTables Package for Shiny App - r

The below Shiny app code below:
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(
fluidRow(
column(12, dataTableOutput('table'))
)
),
server = function(input, output) {
output$table <- DT::renderDataTable(iris)
}
)
triggers the error:
DataTables warning: table id=DataTables_Table_0 - Ajax error. For more information about this error, please see http://datatables.net/tn/7
using the packages:
R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.2, RStudio 1.2.5033
Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8
Package version:
assertthat_0.2.1 backports_1.1.5 base64enc_0.1.3 BH_1.72.0.3
cli_2.0.1 colorspace_1.4.1 crayon_1.3.4 crosstalk_1.0.0
digest_0.6.23 DT_0.11.3 ellipsis_0.3.0 fansi_0.4.1
farver_2.0.1 fastmap_1.0.1 ggplot2_3.2.1 glue_1.3.1
graphics_3.6.2 grDevices_3.6.2 grid_3.6.2 gtable_0.3.0
htmltools_0.4.0.9002 htmlwidgets_1.5.1 httpuv_1.5.2 jsonlite_1.6
labeling_0.3 later_1.0.0 lattice_0.20.38 lazyeval_0.2.2
lifecycle_0.1.0 magrittr_1.5 MASS_7.3.51.4 Matrix_1.2.18
methods_3.6.2 mgcv_1.8.31 mime_0.8 munsell_0.5.0
nlme_3.1.142 pillar_1.4.3 pkgconfig_2.0.3 plyr_1.8.5
promises_1.1.0 R6_2.4.1 RColorBrewer_1.1.2 Rcpp_1.0.3
reshape2_1.4.3 rlang_0.4.2 scales_1.1.0 shiny_1.4.0.9001
sourcetools_0.1.7 splines_3.6.2 stats_3.6.2 stringi_1.4.5
stringr_1.4.0 tibble_2.1.3 tools_3.6.2 utf8_1.1.4
utils_3.6.2 vctrs_0.2.1 viridisLite_0.3.0 withr_2.1.2
xtable_1.8.4 yaml_2.2.0 zeallot_0.1.0
with Chrome 79.0.3945. This is using the latest development packages for shiny and DT after the CRAN packages did not seem to work.
Is there a workaround to this problem?

Updating to the GitHub master versions of the two suggested packages (htmlwidgets and jsonlite) seems to have worked as suggested on GitHub: https://github.com/rstudio/DT/issues/758

Use server=False
As in:
output$tbl <- DT::renderDT(iris, server = FALSE)
Source: https://github.com/rstudio/DT/issues/642

Related

R blogdown::build_site does not generate any files in the public folder

I have tried using blogdown to create a personal website with the gcushen theme. Now, blogdown::serve_site() gives me a preview of my website, which looks perfectly fine. However, I am not able to publish the website online as my public folder is empty.
Here is the information about my session:
> xfun::session_info('blogdown')
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6, RStudio 1.2.5042
Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8
Package version:
base64enc_0.1.3 blogdown_1.13 bookdown_0.29 bslib_0.3.1 digest_0.6.29 evaluate_0.16
fastmap_1.1.0 fs_1.5.2 glue_1.6.2 graphics_3.6.3 grDevices_3.6.3 highr_0.9
htmltools_0.5.3 httpuv_1.6.6 jquerylib_0.1.4 jsonlite_1.8.0 knitr_1.40 later_1.3.0
magrittr_2.0.3 methods_3.6.3 mime_0.12 promises_1.2.0.1 R6_2.5.1 rappdirs_0.3.3
Rcpp_1.0.9 rlang_1.0.6 rmarkdown_2.16 sass_0.4.2 servr_0.24 stats_3.6.3
stringi_1.7.8 stringr_1.4.1 tinytex_0.41 tools_3.6.3 utils_3.6.3 xfun_0.33
yaml_2.3.5
Hugo version: 0.104.0
Thanks to this post (https://github.com/rstudio/blogdown/issues/495), I am aware that I need to use blogdown::build_site() to generate a public folder, but that does not work. I got a very long error message, I have pasted parts of it below.
> blogdown::build_site(local = TRUE, run_hugo = TRUE)
Start building sites …
hugo v0.104.0-c744dbd6edeeb27288c9dd67e0eb92951f911397+extended darwin/amd64 BuildDate=2022-09-23T14:32:56Z VendorInfo=gohugoio
dyld: lazy symbol binding failed: Symbol not found: _utimensat
Referenced from: /Users/minyuchang/Library/Application Support/Hugo/0.104.0/hugo
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _utimensat
Referenced from: /Users/minyuchang/Library/Application Support/Hugo/0.104.0/hugo
Expected in: /usr/lib/libSystem.B.dylib
SIGABRT: abort
PC=0xbf4d9ee m=0 sigcode=0
goroutine 0 [idle]:
syscall.syscall6(0xc000bbcb80?, 0x3d?, 0x8d09108?, 0xc000bbcb80?, 0x3d?, 0xc001085390?, 0x40533d0?)
/usr/local/go/src/runtime/sys_darwin.go:44 +0x99 fp=0xc001085318 sp=0xc001085258 pc=0x4068a39
syscall.utimensat(0xc001085468?, {0xc000bbcb80?, 0xc001085468?}, 0xc001085458, 0x3d?)
/usr/local/go/src/syscall/zsyscall_darwin_amd64.go:353 +0x9c fp=0xc001085390 sp=0xc001085318 pc=0x407e43c
syscall.UtimesNano({0xc000bbcb80, 0x3d}, {0xc001085458, 0x3e?, 0x3d?})
/usr/local/go/src/syscall/syscall_bsd.go:496 +0x79 fp=0xc001085428 sp=0xc001085390 pc=0x407b3d9
os.Chtimes({0xc000bbcb80?, 0x3d}, {0xc000bbcb80?, 0xc0008b2480?, 0x74474e0?}, {0x33?, 0xc0007c2c90?, 0x74474e0?})
/usr/local/go/src/os/file_posix.go:184 +0x1c5 fp=0xc0010854c8 sp=0xc001085428 pc=0x40b1a25
github.com/spf13/afero.OsFs.Chtimes(...)
/root/project/gomodcache/github.com/spf13/afero#v1.9.2/os.go:99
github.com/spf13/afero.(*OsFs).Chtimes(0x0?, {0xc000bbcb80?, 0xa?}, {0x0?, 0x0?, 0x74474e0?}, {0xc001085578?, 0x455bf25?, 0x74474e0?})
<autogenerated>:1 +0x65 fp=0xc001085518 sp=0xc0010854c8 pc=0x448e065
github.com/spf13/afero.(*BasePathFs).Chtimes(0xc0000e4ea0, {0xc0007c2c90?, 0xc000368d20?}, {0xc0007c2ce0?, 0x45763ea?, 0x74474e0?}, {0xc001085608?, 0x457644a?, 0x74474e0?})
/root/project/gomodcache/github.com/spf13/afero#v1.9.2/basepath.go:88 +0x16a fp=0xc0010855c0 sp=0xc001085518 pc=0x448326a
github.com/gohugoio/hugo/hugofs.(*hasBytesFs).Chtimes(0x0?, {0xc0007c2c90?, 0x74474e0?}, {0x0?, 0xedac1a631?, 0x74474e0?}, {0x63e7ea0?, 0x63e7ea0?, 0x74474e0?})
<autogenerated>:1 +0x4b fp=0xc001085618 sp=0xc0010855c0 pc=0x45786eb
github.com/spf13/fsync.(*Syncer).syncstats(0xc001085d90, {0xc0007c2c90, 0xa}, {0xc0007c2ce0, 0xa})
/root/project/gomodcache/github.com/spf13/fsync#v0.9.0/fsync.go:238 +0x31a fp=0xc0010856d0 sp=0xc001085618 pc=0x571349a
github.com/spf13/fsync.(*Syncer).sync.func1()
/root/project/gomodcache/github.com/spf13/fsync#v0.9.0/fsync.go:135 +0x36 fp=0xc001085708 sp=0xc0010856d0 pc=0x5713156
github.com/spf13/fsync.(*Syncer).sync(0xc001085d90, {0xc0007c2c90, 0xa}, {0xc0007c2ce0, 0xa})
/root/project/gomodcache/github.com/spf13/fsync#v0.9.0/fsync.go:171 +0x708 fp=0xc0010859c8 sp=0xc001085708 pc=0x5712b68
github.com/spf13/fsync.(*Syncer).sync(0xc001085d90, {0x63e3ae8, 0x1}, {0x63e3ae8, 0x1})
/root/project/gomodcache/github.com/spf13/fsync#v0.9.0/fsync.go:197 +0xaec fp=0xc001085c88 sp=0xc0010859c8 pc=0x5712f4c
github.com/spf13/fsync.(*Syncer).syncRecover(0xc000e3ed90?, {0x63e3ae8?, 0x1?}, {0x63e3ae8?, 0x1?})
/root/project/gomodcache/github.com/spf13/fsync#v0.9.0/fsync.go:128 +0x6c fp=0xc001085cf0 sp=0xc001085c88 pc=0x571230c
github.com/spf13/fsync.(*Syncer).Sync(0xc000e3ed90, {0x63e3ae8, 0x1}, {0x63e3ae8, 0x1})
/root/project/gomodcache/github.com/spf13/fsync#v0.9.0/fsync.go:103 +0xaa fp=0xc001085d28 sp=0xc001085cf0 pc=0x571222a
github.com/gohugoio/hugo/commands.(*commandeer).copyStaticTo(0xc0001783c0, 0xc0008e9ea0)
/root/project/hugo/commands/hugo.go:675 +0x357 fp=0xc001085de0 sp=0xc001085d28 pc=0x5724ad7
github.com/gohugoio/hugo/commands.(*commandeer).copyStaticTo-fm(0xc000e3ee30?)
<autogenerated>:1 +0x2c fp=0xc001085e00 sp=0xc001085de0 pc=0x573d48c
github.com/gohugoio/hugo/commands.(*commandeer).doWithPublishDirs(0xc0001783c0, 0xc001085f08)
/root/project/hugo/commands/hugo.go:599 +0x163 fp=0xc001085ed0 sp=0xc001085e00 pc=0x57244a3
github.com/gohugoio/hugo/commands.(*commandeer).copyStatic(0x8?)
/root/project/hugo/commands/hugo.go:581 +0x39 fp=0xc001085f28 sp=0xc001085ed0 pc=0x57242b9
github.com/gohugoio/hugo/commands.(*commandeer).fullBuild.func2()
/root/project/hugo/commands/hugo.go:304 +0x2a fp=0xc001085f78 sp=0xc001085f28 pc=0x572292a
golang.org/x/sync/errgroup.(*Group).Go.func1()
/root/project/gomodcache/golang.org/x/sync#v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57 +0x67 fp=0xc001085fe0 sp=0xc001085f78 pc=0x4dc6ea7
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc001085fe8 sp=0xc001085fe0 pc=0x406c501
created by golang.org/x/sync/errgroup.(*Group).Go
/root/project/gomodcache/golang.org/x/sync#v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:54 +0x8d
......
As a result, my public folder only has a "uploads" subfolder, and nothing is in it.
Could anyone helps me figure out what is going wrong?

Shiny's ActionButton not responding

I can't seem to manage to get the action button in shiny working. Nothing happens when i press "click me" and there is no error message.
Does anyone have a clue what might be wrong?
library(shiny)
ui <- fluidPage(
tags$head(tags$script(src = "message-handler.js")),
actionButton("do", "Click Me")
)
server <- function(input, output, session) {
observeEvent(input$do, {
session$sendCustomMessage(type = 'testmessage',
message = 'Thank you for clicking')
})
}
shinyApp(ui, server)
here is my session info:
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252 LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C LC_TIME=Swedish_Sweden.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_1.4.0.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 packrat_0.5.0 digest_0.6.27 later_1.1.0.1 mime_0.9 R6_2.5.0 xtable_1.8-4 jsonlite_1.7.2 magrittr_2.0.1
[10] rlang_0.4.10 promises_1.1.0 tools_3.6.3 httpuv_1.5.2 rsconnect_0.8.16 fastmap_1.0.1 compiler_3.6.3 htmltools_0.5.1.1

knitr cannot find pdflatex when creating pdf from shiny app

I am trying to create a shiny App that offers users a choice of canned reports from a database that renders reactively, and then offers users the option to download a pdf of their desired report. I am running into trouble getting knitr to discover pdflatex to make the pdf. I originally tried using MikTex, but on advice of other posts removed MikTex and instead used tinytex. I followed the guidance here: https://yihui.org/tinytex/r/#debugging. The shiny app works fine, but when I click the download button, R initially starts the process of compiling, but once I click save when the dialog button launches, R throws this error (I include the verbose output as suggested by Yuhui Xie - the tinytex package author):
processing file: Reports.Rmd
|.................. | 25%
ordinary text without R code
|.................................... | 50%
label: unnamed-chunk-1
|...................................................... | 75%
ordinary text without R code
|........................................................................| 100%
label: unnamed-chunk-2
output file: Reports.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Reports.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output pandoc5ac42d2964ee.tex --lua-filter "C:\Users\SCMCKENZIE\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\SCMCKENZIE\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --highlight-style tango --pdf-engine xelatex --variable graphics --variable "geometry:margin=1in"
Warning: Error in : LaTeX failed to compile C:\Users\SCMCKE~1\AppData\Local\Temp\Rtmp0a6jRk\file5ac45df413ce.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
[No stack trace available]
Here is my SessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plyr_1.8.6 rmarkdown_2.6 knitr_1.29
[4] tmap_3.3 rgeos_0.5-3 sp_1.4-1
[7] sf_0.9-7 xtable_1.8-4 readr_1.4.0
[10] shinydashboard_0.7.1 odbc_1.2.3 DBI_1.1.0
[13] shiny_1.5.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 lattice_0.20-41 png_0.1-7 class_7.3-17
[5] digest_0.6.25 mime_0.9 R6_2.4.1 evaluate_0.14
[9] e1071_1.7-3 pillar_1.4.6 rlang_0.4.7 rstudioapi_0.11
[13] raster_3.3-13 blob_1.2.1 stringr_1.4.0 htmlwidgets_1.5.1
[17] bit_1.1-15.2 tinytex_0.29 compiler_4.0.2 httpuv_1.5.4
[21] xfun_0.20 pkgconfig_2.0.3 tmaptools_3.1-1 base64enc_0.1-3
[25] htmltools_0.5.0 tidyselect_1.1.0 tibble_3.0.3 codetools_0.2-16
[29] XML_3.99-0.4 viridisLite_0.3.0 crayon_1.3.4 dplyr_1.0.0
[33] later_1.1.0.1 grid_4.0.2 jsonlite_1.7.0 lwgeom_0.2-5
[37] lifecycle_0.2.0 magrittr_1.5 units_0.6-7 KernSmooth_2.23-17
[41] stringi_1.4.6 promises_1.1.1 leafsync_0.1.0 leaflet_2.0.4.1
[45] ellipsis_0.3.1 generics_0.0.2 vctrs_0.3.2 RColorBrewer_1.1-2
[49] tools_4.0.2 dichromat_2.0-0 bit64_0.9-7 leafem_0.1.3
[53] glue_1.4.1 purrr_0.3.4 hms_0.5.3 crosstalk_1.1.0.1
[57] abind_1.4-5 parallel_4.0.2 fastmap_1.0.1 yaml_2.2.1
[61] stars_0.5-1 classInt_0.4-3
I have ensured that I have selected my Global Options in RStudio to use knitr and pdflatex. Sys.which('pdflatex') gives me:
pdflatex
"C:\\Users\\SCMCKE~1\\AppData\\Roaming\\TinyTeX\\bin\\win32\\pdflatex.exe"
And tinytex::tlmgr_conf() gives me:
tlmgr conf
=========================== version information ==========================
tlmgr revision 57424 (2021-01-15 03:30:58 +0100)
tlmgr using installation: C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX
TeX Live (https://tug.org/texlive) version 2020
==================== executables found by searching PATH =================
PATH: C:\Users\SCMCKE~1\AppData\Roaming\TinyTeX\tlpkg\tlperl\bin;C:\Users\SCMCKE~1\AppData\Roaming\TinyTeX\bin\win32;C:\rtools40\usr\bin;C:\Program Files\R\R-4.0.3\bin\x64;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\SCMCKENZIE\AppData\Roaming\TinyTeX\bin\win32;C:\Users\SCMCKENZIE\AppData\Local\Microsoft\WindowsApps;C:\Users\SCMCKENZIE\AppData\Local\Programs\MiKTeX\miktex\bin\x64
dvipdfmx: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/dvipdfmx.EXE
dvips: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/dvips.EXE
fmtutil: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/fmtutil.EXE
kpsewhich: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/kpsewhich.EXE
luatex: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/luatex.EXE
mktexpk: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/mktexpk.EXE
pdftex: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/pdftex.EXE
tex: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/tex.EXE
tlmgr: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/tlmgr.BAT
updmap: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/updmap.EXE
xetex: C:/Users/SCMCKE~1/AppData/Roaming/TinyTeX/bin/win32/xetex.EXE
=========================== active config files ==========================
config.ps: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/dvips/config/config.ps
fmtutil.cnf: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/web2c/fmtutil.cnf
mktex.cnf: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/web2c/mktex.cnf
pdftexconfig.tex: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/tex/generic/tex-ini-files/pdftexconfig.tex
texmf.cnf: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf.cnf
texmf.cnf: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/web2c/texmf.cnf
updmap.cfg: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist/web2c/updmap.cfg
============================= font map files =============================
kanjix.map: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map
pdftex.map: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map
ps2pk.map: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts/map/dvips/updmap/ps2pk.map
psfonts.map: c:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts.map
=========================== kpathsea variables ===========================
ENCFONTS=.;{C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/fonts/enc//
SYSTEXMF=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var;C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local;C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist
TEXCONFIG={C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/dvips//
TEXFONTMAPS=.;{C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/fonts/map/{kpsewhich,pdftex,dvips,}//
TEXMF={C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}
TEXMFCONFIG=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config
TEXMFDBS={!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}
TEXMFDIST=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist
TEXMFHOME=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local
TEXMFLOCAL=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local
TEXMFMAIN=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist
TEXMFSYSCONFIG=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config
TEXMFSYSVAR=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var
TEXMFVAR=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var
TEXPSHEADERS=.;{C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/{dvips,fonts/{enc,type1,type42,type3}}//
VARTEXFONTS=C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var/fonts
WEB2C={C:/PROGRA~1/R/R-40~1.2/share/texmf,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-local,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-config,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-var,!!C:/Users/SCMCKENZIE/AppData/Roaming/TinyTeX/texmf-dist}/web2c
==== kpathsea variables from environment only (ok if no output here) ====
In case it is a matter of my coding, below is a reproducible R script:
##Loading Necessary Packages
library(shiny)
library(shinydashboard)
library(rmarkdown)
library(knitr)
library(plyr)
##Getting data for reproducibility
data("iris")
data("airquality")
names(airquality)[5]<-"Species"#To allow for using the same plyr code in server function on both data sets
####Creating Shiny App####
##User Interface
ui<-dashboardPage(
dashboardHeader(title="FAKE SHINY APPLICATION"),
dashboardSidebar(
sidebarMenu(tabName="REPORTS",
menuItem("OPTIONS", tabName = "SOME MENU OPTIONS",
radioButtons(inputId = "REPORT", label = "Select Something", choices = c("Iris", "AQ")),
downloadButton(outputId = "DWNLD", "Download Report")
)
)
),
dashboardBody(
tableOutput(outputId = "TABLE"),
plotOutput(outputId = "PLOT")
)
)
##Server Function##
server<-function(input, output){
##Reactive Plot##
output$PLOT<-renderPlot({
RPT<-list(Iris = iris, AQ = airquality)
DF<-RPT[[input$REPORT]]
pairs(DF[,c(1:4)])})
##Reactive Table##
output$TABLE<-renderTable({
RPT<-list(Iris = iris, AQ = airquality)
DF<-RPT[[input$REPORT]]
rpt_tbl<-ddply(DF, "Species", colwise(mean))
xtable(rpt_tbl)
})
##Download As PDF##
output$DWNLD<-downloadHandler(
filename=paste(input$REPORT, "pdf", sep="."),
content<-function(file){
RPT<-list(iris, airquality)
names(RPT)<-c("Iris", "AQ")
tmp<-file.path(tempdir(), "Reports.Rmd")
file.copy(paste(getwd(),"Reports.Rmd", sep="/"), tmp, overwrite=TRUE)
params<-list(DF
rmarkdown::render(tmp, output_file = file,
params = params,
envir = new.env(parent = globalenv()
))#End render
}
)
}
##Launch Shiny App##
shinyApp(ui=ui, server = server)
And here is the script for the Rmarkdown document saved as Reports.Rmd:
---
title: "FAKE REPORT"
output: pdf_document
params:
DF: NA
---
Fake Report Output
```{R}
rpt_tbl<-ddply(params$DF, "Species", colwise(mean))
xtable(rpt_tbl)
```
More Fake Output
```{R}
pairs(params$DF[,c(1:4)])
```
I have scoured Stack Overflow and RStudio answers, but haven't found any that seem to be my problem. Part of me is wondering if this is a platform issue. Any help would be much appreciated. Thanks so much.
Take Care,
-Sean
After much searching and testing, I found out that the problem was not with tinytex or pdflatex, but rather my call to rmarkdown::render() That led me to this answer on GitHub https://github.com/rstudio/shiny/issues/1831. Apparently, when rmarkdown::render() is called within downloadHandler(), you should NOT specify the output_file argument in render() Instead you need to rename the file AFTER rendering.
Here is the correct code (simply replace the call to downloadHandler() in the script from my original question.
output$DWNLD<-downloadHandler(
filename=paste0(input$REPORT, ".pdf"),
content<-function(file){
RPT<-list(iris, airquality)
names(RPT)<-c("Iris", "AQ")
tmp <- file.path(tempdir(), "Reports.Rmd", fsep="\\")
file.copy("F:/Apps/DNR_TRIS/Shiny_report_scripts/SQL_SCRIPTS/Reports.Rmd", tmp, overwrite = TRUE)
out<-RPT[[input$REPORT]]
params<-list(out)
names(params)<-"DF"
out<-rmarkdown::render(tmp,
params = params,
envir = new.env(parent = globalenv()
))#End render
file.rename(out, file)
}
)

defining operator doesn't work anymore (Error in UseMethod("%op%"): no applicable method for '%op%' applied to an object of class "character")

In my toy package, I have defined %+% operator as an alias to paste0(). Trying to reduce interference with other packages, I realized it the following way:
`%+%` <- function(...) UseMethod("%+%")
`%+%.character` <- paste0
`%+%.numeric` <- paste0
`%+%.default` <- function (arg1, arg2){
e <- parent.env(getEnvByName(.GlobalEnv,'package:mypackagename'));
if (exists('%+%', envir = e)) get('%+%',envir = e)(arg1,arg2);
}
i.e. I override it only for character and numeric arguments, otherwise it tries to find if the method was previously defined.
It was working just fine until recently when it started giving an error:
'a' %+% 'b'
# Error in UseMethod("%+%") :
# no applicable method for '%+%' applied to an object of class "character"
It only fails when called outside of the package. If I define a function within the package, it works correctly:
# testab2() is defined in R file as a part of the package:
testab2 <- function(inpA, inpB){
print (inpA %+% inpB)
}
# when called outside of the package:
testab2('a','b')
# ab
I am pretty sure I didn't change anything in my code, so I'm wondering if it could be caused by R update. What could have changed and how to make it work back?
P.S. getEnvByName() is my helper function that searches for an object in parent environments:
getEnvByName <- function(inpEnv=.GlobalEnv, lookFor){
e <- inpEnv;
while (environmentName(e) != 'R_EmptyEnv' & environmentName(e)!=lookFor) e <- parent.env(e);
if (environmentName(e) != lookFor) return(NULL);
return(e);
}
And the exporting was done by the following lines in the NAMESPACE file:
exportPattern("^[[:alpha:]]+")
exportPattern("%.*%")
export("%+%.default")
export("%+%.character")
P.P.S. sessionInfo:
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
system code page: 1251
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] vautils_0.1.1.105 magrittr_1.5 data.table_1.13.0
loaded via a namespace (and not attached):
[1] dplyr_1.0.2 crayon_1.3.4 grid_4.0.2 R6_2.4.1 lifecycle_0.2.0 gtable_0.3.0
[7] scales_1.1.1 ggplot2_3.3.2 pillar_1.4.6 rlang_0.4.7 rstudioapi_0.11 generics_0.0.2
[13] vctrs_0.3.4 ellipsis_0.3.1 tools_4.0.2 glue_1.4.2 purrr_0.3.4 munsell_0.5.0
[19] compiler_4.0.2 pkgconfig_2.0.3 colorspace_1.4-1 tidyselect_1.1.0 tibble_3.0.3
To export S3 methods, your NAMESPACE file needs to (in your case) contain the following declarations:
export(`%+%`)
S3method(`%+%`, default)
S3method(`%+%`, character)
S3method(`%+%`, numeric)
That is, export the %+% generic, and declare S3 methods for the methods.
Better yet, instead of manually editing the NAMESPACE file use ‘roxygen2’, which generates the correct declarations for you based on the #export documentation tag.

Permission denied to write a table with dbWriteTable in RPostgreSQL

I've been trying to solve a problem with the RPostgreSQL package for quite some time. My code:
path_ene <- "C:/Users/omen03/ENE"
nene <- "ene_2010_02_efm.csv"
drv <- dbDriver("PostgreSQL")
con = dbConnect(drv, user="postgres", password="mypassword",
host="localhost", port=5432, dbname="ENE")
tn = "ene_2010_02_efm";
dbRemoveTable(con,tn);
dbWriteTable(conn = con, name = tn, value = paste0(path_ene,"/",nene),
sep = ",", overwrite = FALSE))
When executing the code described above, I throw the following error:
Error in postgresqlExecStatement (conn, statement, ...):   
RS-DBI driver: (could not Retrieve the result: ERROR:
Could not open file «C: /Users/omen03/ENE/ene_2010_02_efm.csv» for reading: Permission denied
HINT: COPY FROM tells the PostgreSQL server process to read a
file. You may want to use a client-side facility such as psql \ copy.
) In addition: Warning message: In postgresqlImportFile (conn, name,
value, ...):    could not load data into table
when I try without specifying the file path, it throws me another error
dbRemoveTable(con,tn);
dbWriteTable(conn = con, name = tn, value = nene),
sep = ",", overwrite = FALSE))
Error in postgresqlExecStatement (conn, statement, ...):    RS-DBI
driver: (could not Retrieve the result: ERROR: could not open file Â
«./ ene_2010_02_efm» for reading: No such file or directory
HINT:
COPY FROM tells the PostgreSQL server process to read a file. You may
want to use a client-side facility such as psql \ copy. ) In addition:
Warning message: In postgresqlImportFile (conn, name, value, ...):   
could not load data into table
Update:
Taking into account the error message, I decided to use sql directly to insert the csv values in each of the tables in the database. For that I used a couple of functions
createEmptyTable <- function(con,tn,df) {
sql <- paste0("create table \"",tn,"\" (",paste0(collapse=',','"',names(df),'" ',sapply(df[0,],postgresqlDataType)),");");
dbSendQuery(con,sql);
invisible();
};
Taken from: How to write a table in PostgreSQL from R?
and
#tn: Table name
#c_names: column names of each table (a list)
#source: The path to each csv files
insert_data = function(tn, source){
sql = paste0('COPY ',tn,' FROM \'',paste0(path_ene,'\\',source),'\' DELIMITER \',\' CSV HEADER')
dbSendQuery(con, sql);
}
insert_data(tn[1], paste0(path_ene, "/",nene[1]))
Anyway, I still get a very similar error.
Error in postgresqlExecStatement (conn, statement, ...):    RS-DBI
driver: (could not Retrieve the result: ERROR: Could not open file Â
«C: /Users/omen03/ENE/ene_2010_02_efm.csv» for reading: Permission
denied HINT: COPY FROM tells the PostgreSQL server process to read a
file. You may want to use a client-side facility such as psql \ copy.
)
My session info:
R version 3.6.1 (2019-07-05) Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale: [1] LC_COLLATE=Spanish_Chile.1252 LC_CTYPE=Spanish_Chile.1252
LC_MONETARY=Spanish_Chile.1252 LC_NUMERIC=C [5]
LC_TIME=Spanish_Chile.1252
attached base packages: [1] stats graphics grDevices utils
datasets methods base
other attached packages: [1] RPostgreSQL_0.6-2 DBI_1.0.0
foreign_0.8-71 captioner_2.2.3 kableExtra_1.1.0 wordcloud_2.6
tidytext_0.2.2 gridExtra_2.3 [9] gtable_0.3.0
readstata13_0.9.2 RColorBrewer_1.1-2 ggrepel_0.8.1 pbapply_1.4-2
srvyr_0.3.6 data.table_1.12.6 lubridate_1.7.4 [17]
stringi_1.4.3 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.3
purrr_0.3.3 readr_1.3.1 tidyr_1.0.0 tibble_2.1.3
[25] ggplot2_3.2.1 tidyverse_1.3.0
loaded via a namespace (and not attached): [1] httr_1.4.1
jsonlite_1.6 viridisLite_0.3.0 splines_3.6.1 modelr_0.1.5
assertthat_0.2.1 cellranger_1.1.0 sessioninfo_1.1.1 [9]
pillar_1.4.3 backports_1.1.5 lattice_0.20-38 glue_1.3.1
digest_0.6.23 rvest_0.3.5 colorspace_1.4-1 htmltools_0.4.0
[17] Matrix_1.2-17 survey_3.36 pkgconfig_2.0.3 broom_0.5.2
haven_2.2.0 scales_1.1.0 webshot_0.5.2 generics_0.0.2
[25] withr_2.1.2 lazyeval_0.2.2 cli_2.0.0
survival_2.44-1.1 magrittr_1.5 crayon_1.3.4 readxl_1.3.1
evaluate_0.14 [33] tokenizers_0.2.1 janeaustenr_0.1.5 fs_1.3.1
fansi_0.4.0 nlme_3.1-140 SnowballC_0.6.0 xml2_1.2.2
tools_3.6.1 [41] hms_0.5.2 mitools_2.4
lifecycle_0.1.0 munsell_0.5.0 reprex_0.3.0 compiler_3.6.1
rlang_0.4.2 grid_3.6.1 [49] rstudioapi_0.10
rmarkdown_1.18 R6_2.4.1 knitr_1.26 zeallot_0.1.0
parallel_3.6.1 Rcpp_1.0.3 vctrs_0.2.1 [57]
dbplyr_1.4.2 tidyselect_0.2.5 xfun_0.11
Finally, I found the answer by looking for the problem of directly importing data into postgresql. It was enough to change the configuration of the folder containing the .csv files.
I reproduce this answer that was the one I finally used.
Right click the folder containing the data file(s) that permission was denied to and then click Properties.
In the Folder's Properties window, select the Security tab.
Click the Edit button. In the "Permissions for the folder" window that opened, click the Add... button.
Type Everyone into the "Enter the object names to select" text area box.
Click OK and the window will close.

Resources