Is there any way to get something like the following in r markdown?
name: date of birth:
So, I'm looking to have text, data, blank space, text and data within one line in my html output after knitting.
Is there any way to get something like the following in r markdown?
name: date of birth:
So, I'm looking to have text, data, blank space, text and data within one line in my html output after knitting.
---
title: "R Notebook"
output:
html_document:
df_print: paged
---
```{r}
library(htmltools)
library(purrr)
mynames <- c("name1","name2")
my_div <- function(x){
div(style="margin-right:2em;",
"name: ",x)
}
div(style="display:flex;",
map(mynames,
my_div))
```
In addition to @nirgrahamuk's response, below is a way to do it for a single instance in-line. The data is in the code chunk, which is referenced in-line with `r your_code
`. Please note the code chunk below only has two backticks (``) to show properly in this post. If copying and pasting into a .Rmd, be sure to add the third backtick.
---
title: ""
output: html_document
---
``{r include=FALSE}
names = c('Name1', 'Name2', 'Name3')
dob = c('1980-03-04', '1985-05-23', '1997-11-08')
``
name: `r names[1]` date of birth: `r dob[1]`
Thank you both very much. Very handy to know this!
Say I want to add "Name: person1" near the left-hand margin and "Date of Birth: 5/30/1989" near the right-hand margin on the same line. Is there an easy way to do this without writing & nbsp; repeatedly? Note I intentionally included a space so the nbsp part would appear.
This topic was automatically closed 45 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.