Search code examples
rmarkdown

Displaying list in R markdown without commas


I've been trying to display this list in R markdown without the commas in between items.

Here is the dataset:

print(reg.order)
[1] "North Pacific"   "Pacific"         "Western Pacific" "New England"    
[5] "Mid-Atlantic"    "South Atlantic"  "Gulf of Mexico" 

And here is the code:

{r Paragraph_5, echo=FALSE, warning=FALSE, message=FALSE}
for (reg00 in 1:length(reg.order)){
  place <- reg.order[reg00]
  place[reg00] <- paste("**",place, "**", "\n\n", sep = "")
}
`r place`

This is what I keep getting:

and this is what I want:

enter image description here

Any suggestions?


Solution

  • ```{r echo=FALSE}
    reg.order <- c("North Pacific","Pacific","Western Pacific","New England",
                   "Mid-Atlantic","South Atlantic","Gulf of Mexico" )
    place <- paste("**", reg.order, "**", collapse = "  \n")
    ```
    `r place`
    

    Resulting HTML render is:

    <p>
    ** North Pacific **<br />
    ** Pacific **<br />
    ** Western Pacific **<br />
    ** New England **<br />
    ** Mid-Atlantic **<br />
    ** South Atlantic **<br />
    ** Gulf of Mexico **
    </p>