'object not found' error when knitting to HTML in RMarkdown - r

I am testing RMarkdown for the first time and am running into an issue when trying to knit anything to HTML. For example: I attempt to knit the following to HTML
# Say Hello to markdown
Markdown is an **easy to use** format for writing reports. It resembles what you naturally write every time you compose an email. In fact, you may have already used markdown *without realizing it*. These websites all rely on markdown formatting
* [Github](www.github.com)
* [StackOverflow](www.stackoverflow.com)
* [Reddit](www.reddit.com)
The above is taken directly from an example on this page: http://rmarkdown.rstudio.com/articles_intro.html
However, when I use the Knit to HTML button I receive this error:
Error: object 'a' not found
Execution halted
Maybe this is a simple question that I am not seeing the answer to, but I do not know how to interpret and correct this error message, as nowhere in my Markdown file am I calling any sort of object 'a'. Thank you for your assistance!

Related

Link chrome to Rstudio for pagedown (Rmarkdown)

I want to convert my html document, created on Rmarkdown to pdf.
One of the way is to use the pagedown package.
However, when I add:
knit: pagedown::chrome_print
in the yaml header, I get the error:
Error in find_chrome() : Cannot find Google Chrome or Edge automatically from the Windows Registry Hive.
Please pass the full path of chrome.exe or msedge.exe to the 'browser' argument
or to the environment variable 'PAGEDOWN_CHROME'.
However, i have no idea on how to link the Chrome browser to rstudio, or where can I access to 'PAGEDOWN_CHROME'.
I tried:
knit: pagedown::chrome_print(browser="C:/Users/johndoe/AppData/Roaming/Microsoft/Windows/Start Menu/Programs"
which is the path to Chrome but the knitting systematically hangs without giving an error.
I am sure this is an easy procedure but but I'm a beginner at this stuff.
I've done a lot of research on SO and the internet, but obviously everyone knows how to do it !
Thanks :-)

Is it possible to directly embed a Shiny app in a bookdown document?

By "directly" I mean not by uploading the app and then using knitr::include_app, but rather entering the source code of the app itself into the Bookdown document.
Rmarkdown supports this, but neither this approach, nor this seems to work with Bookdown. (The former gives an "Error: path for html_dependency not provided" error, the latter displays an empty frame.)

Error message while trying to create PDF in R Markdown

I'm trying to create a PDF in R Markdown and I keep getting this error message every time I try to click "Knit to PDF":
output file: test_4_for_r.knit.md
Output created: test_4_for_r.pdf
Error in tools::file_path_as_absolute(output_file) :
file 'test_4_for_r.pdf' does not exist
Calls: <Anonymous> -> <Anonymous>
In addition: Warning message:
In readLines(logfile) : incomplete final line found on 'test_4_for_r.log'
Execution halted
I do not have a lot of familiarity with RStudio, so I have no idea why I'm getting this message. I've read several things online saying creating PDFs in R Markdown requires several packages, but so far I've only found the name of knitr. That is the only one I have currently installed. I'm not sure if that is the issue or not.
Can someone please point me in the right direction on how to remedy this? Any help would be GREATLY appreciated.
In R-Studio Tools > Global Options, under the Sweave tab, try changing "Weave Rnw using:" from sweave to knitr. Also try
install.packages('tinytex')
tinytex::install_tinytex()
and then try to knit your PDF.
If those don't work, please paste the markdown code giving you trouble. Could you knit the example markdown file, found when you File > New File > R Markdown?

Knitr preamble error results in "pandoc document conversion failed with error 43"

Rstudio Version 0.99.441; Windows 7 enterprise; knitr 1.10.5; MiKTex 0.4.5 r.1280 (2.9 64-bit)
I have a an error on my office computer when trying to knit PDF's in Rstudio, there are no problems knitting to HTML or word. The problem may be related to updates because knitting used to work fine and my home computer can knit to pdf without issue, however I took my computer home to update and the problem is still there.
My error message was as follows
"pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43"
I created a new file using the template example in Rstudio attempted to knit, then inspected the TEX output. I traced the error to the last paragraph of the preamble.
\setlength{\droptitle}{-2em}
\title{Untitled}
\pretitle{\vspace{\droptitle}\centering\huge}
\posttitle{\par}
\author{user name}
\preauthor{\centering\large\emph}
\postauthor{\par}
\predate{\centering\large\emph}
\postdate{\par}
\date{\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{14}
\itemsep1pt\parskip0pt\parsep0pt
\item
juni 2015
\end{enumerate}}
by removing the last 7 lines to do with enumerate and the date then running the TEX code the document prints as a PDF. Why is this happening and what can I do about it so the document knits at first click from Rstudio?
You should show the YAML frontmatter of the R Markdown document. Guessing from my experience, the error was caused by
---
date: "14. Juni 2015"
---
Any number followed by a period (e.g. 14.) will be treated as an item in a numbered list. You need to either remove or escape the period . (by \\.) in the date field. The same issue has been reported before.
This error can also be form having a curly quote or certain other characters. I spent ages on this pandoc error 43 before realising it was a block of text I had copied over form word.
e.g. Bob’s vs bob's
Another way to create this error is from having 'æ', 'ø' or 'å' in the file name.
My screw-up that resulted in this error was forgetting to put dollar signs around some inline latex code. I did
\theta
Instead of
$\theta$

gvisMotionChart is not working in R markdown file

I need to embed gvisMotionChart into an R markdown file and find an example interactive which is really helpful. However when it comes to the googlevis plotting I keep getting this error when I press the "run code" button:
connection to openCPU failed:
error
undefined
NetworkError: A network error occurred
Can anybody figure out the solutions?
Thanks in advance.
The googleVis package creates the javascript that has to be embedded into an HTML document in order for the interactive plot to run on a webpage. You won't be able to get it to work in the console or in Rstudio for that reason. The only way to know for sure if it's working is to knit it to HTML, and then publish it to Rpubs (or anywhere else online). Once it is online it will work. Depending on your browser settings, you might be able to get it to work by opening the HTML locally, but the browser often blocks the embedded plot when opened locally.
Without seeing your actual code, I can't provide you with anything more specific than that.
EDIT: I thought I would add that several months ago I made a markdown file detailing interactive plots in R for a class. You can find it here: http://rpubs.com/crmhaske/uwloo670_Interactive_Plots
If you scroll down to the very end you'll see the example I did using gvisMotionChart. You have to make sure the place where you print the graph is in it's own chunk, and that results is asis:
```{r results='asis'}
print(p,'chart')
```

Resources