How can I use a variable name with space inside R Markdown inline code?
Minimal Working Example
---
title: "MWE"
author: "Raniere Silva"
date: "08/11/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
`foo bar` <- 1
```
'foo bar' is `r `foo bar``.
Use Cases
CSV column name has space on it.
You can do something like this:
---
title: "MWE"
author: "Raniere Silva"
date: "08/11/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
`foo bar` <- 1
```
'foo bar' is `r get("foo bar")`.
This obviously a rich incentive to not use spaces in variable names. If they occur in data files, then they should really be repaired using (for example) janitor::clean_names()
.
Stephen
2 Likes
system
Closed
November 23, 2021, 2:34am
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.