Ashim Kapoor
2019-Oct-14 11:35 UTC
[R] Double / single backticks for inline R code in an Rmarkdown file
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]]
Jeff Newmiller
2019-Oct-14 13:37 UTC
[R] Double / single backticks for inline R code in an Rmarkdown file
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 at 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 at 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.
Ashim Kapoor
2019-Oct-14 13:47 UTC
[R] Double / single backticks for inline R code in an Rmarkdown file
Dear Jeff, Many thanks for your reply. Best, Ashim On Mon, Oct 14, 2019 at 7:07 PM Jeff Newmiller <jdnewmil at 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 at 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 at 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. >[[alternative HTML version deleted]]
Yihui Xie
2019-Oct-14 14:00 UTC
[R] Double / single backticks for inline R code in an Rmarkdown file
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 at
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 at
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 at 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 at 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.