[R] Double / single backticks for inline R code in an Rmarkdown file

Yihui Xie x|e @end|ng |rom y|hu|@n@me
Mon Oct 14 16:00:20 CEST 2019


params$data is "hawaii" in this case, so the output of

  ``r params$data``

is

  `hawaii`

The double backticks don't have any special meaning here. Only the
inside pair of backticks (i.e. `r `) makes sense to R Markdown (or
precisely speaking, knitr). The outside pair will be left untouched
after knitr evaluates the inline R expression `r params$data`. After
evaluation, there won't be double backticks. This has nothing to do
with the left curly double quote LaTeX. The result `hawaii` will be
converted to <code>hawaii</code> if the output format is HTML (or
\texttt{hawaii} if the output format is LaTeX), but the extra
backticks in the original Rmd document is completely optional. It all
depends on whether you want to place the result in a code tag or
command.

Regards,
Yihui
--
https://yihui.name

On Mon, Oct 14, 2019 at 8:42 AM Jeff Newmiller <jdnewmil using dcn.davis.ca.us> wrote:
>
> No, you don't misunderstand. But you might want to be aware that targeting PDF output uses LaTeX which regards double backticks as a method of encoding a left curly double quote mark, so this error could derive from an incomplete adaptation of the Rmd file for HTML output even though such a symbol doesn't make sense there in PDF either.
>
> On October 14, 2019 4:35:26 AM PDT, Ashim Kapoor <ashimkapoor using gmail.com> wrote:
> >Dear All,
> >
> >I am reading this file :-
> >
> >https://rmarkdown.rstudio.com/lesson-6.html
> >
> >My query is : In line 14 of the above file, ie.
> >
> >The [marmap](https://cran.r-project.org/web/packages/marmap/index.html)
> >package provides tools and data for visualizing the ocean floor. Here
> >is an
> >example contour plot of marmap's ``r params$data`` dataset.
> >
> >Should not the phrase rparams$data be within SINGLE backticks ?
> >
> >Do I misunderstand?
> >
> >Thank you,
> >Ashim
> >
> >       [[alternative HTML version deleted]]
> >
> >______________________________________________
> >R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list