0

I am trying to create a PDF export of some of my R outputs (tables and graphs). I created a .Rmd document and I have tried to run the simplest of code setting up the document, but I immediately get an error. The same error pops up when I click the "Knit" button at the top of the R studio window.

The code:

 ---
 title: "Example"
 author: "Me"
 output: pdf_document
 ---

 {r setup, include=FALSE}

 knitr::opts_chunk$set(echo = FALSE)

The error:

Error in namespaceExport(ns, exports) : 
  undefined exports: Sweave2knitr, all_labels, all_patterns, all_rcpp_labels, asis_output, cache_engines, clean_cache, combine_words, current_input, dep_auto, dep_prev, engine_output, extract_raw_output, fig_chunk, fig_path, hook_ffmpeg_html, hook_gifski, hook_mogrify, hook_movecode, hook_optipng, hook_pdfcrop, hook_plot_asciidoc, hook_plot_custom, hook_plot_html, hook_plot_md, hook_plot_rst, hook_plot_tex, hook_plot_textile, hook_pngquant, hook_purl, hook_r2swf, hook_scianimator, hooks_asciidoc, hooks_html, hooks_jekyll, hooks_latex, hooks_listings, hooks_markdown, hooks_rst, hooks_sweave, hooks_textile, image_uri, imgur_upload, include_app, include_graphics, include_url, inline_expr, is_html_output, is_latex_output, is_low_change, kable, kables, knit, knit2html, knit2pandoc, knit2pdf, knit2wp, knit_child, knit_code, knit_engines, knit_exit, knit_expand, knit_filter, knit_global, knit_hooks, knit_meta, knit_meta_add, knit_params, knit_params_yaml, knit_patterns, knit_print, kni
Calls: loadNamespace ... namespaceImportFrom -> asNamespace -> loadNamespace -> namespaceExport
In addition: Warning message:
S3 methods '$.knitr_strict_list', 'is_low_change.default', 'knit_print.default', 'knit_print.knit_asis', 'knit_print.knit_asis_url', 'knit_print.knitr_kable', 'print.knitr_kable', 'process_group.block', 'process_group.inline', 'process_tangle.block', 'process_tangle.inline', 'sew.character', 'sew.default', 'sew.error', 'sew.html_screenshot', 'sew.knit_asis', 'sew.knit_embed_url', 'sew.knit_image_paths', 'sew.list', 'sew.message', 'sew.recordedplot', 'sew.source', 'sew.warning' were declared in NAMESPACE but not found 
Execution halted

I've tried updating all of my packages and restarting R. I've also tried changing the working directory.

It also seems like Knitr package isn't loading (it's not checked in the packages tab). I just tried checking the box and I received a "fatal error" message and R needed to restart. Once it restarted, I was able to check the box without a "fatal error" but the original error still appears in the console.

Casey
  • 21
  • 4

1 Answers1

0

To solve this issue, I tried uninstalling the Knitr package but received an error:

  cannot delete reparse point 'C:\Users\R\win-library\4.1/knitr/R', reason 'There is a mismatch between the tag specified in the request and the tag present in the reparse point'
Warning in install.packages :
  cannot remove prior installation of package ‘knitr’
Warning in install.packages :
  cannot delete reparse point 'C:\Users\R\win-library\4.1/knitr/R', reason 'There is a mismatch between the tag specified in the request and the tag present in the reparse point'
Warning in install.packages :
  restored ‘knitr’

To resolve this, I changed the name of the folder for the package to xxx and then installed the package again without any issues.

Once I had reinstalled, a new error appeared prompting me to install latexpdf.

I tried to Knit the document again and a new error appeared which lead me to this post: Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info. Execution halted

As stated in that StackOverflow answer, I ran tinytex::install_tinytex()

After doing this I was able to knit a PDF

Casey
  • 21
  • 4