How to show a string vector as bullet list

1,716 views
Skip to first unread message

Daniel Fan

unread,
Feb 24, 2017, 3:16:29 AM2/24/17
to knitr
HI all,

I'd like to show a string vector as bullet list in rmarkdown. How can I do that? I have web searching for a while and found nothing.

For example, I have

##
```{r}
  string.list <- c('first item', 'second item', 'third item')
```

Is there any function that I can apply to string.list, to generate

- first item
- second item
- third item

in the compiled markdown file?

Yihui Xie

unread,
Feb 24, 2017, 3:21:05 AM2/24/17
to Daniel Fan, knitr
```{r results='asis'}
string.list <- c('first item', 'second item', 'third item')
cat(paste('-', string.list), sep = '\n')
```

Regards,
Yihui
--
https://yihui.name
> --
> You received this message because you are subscribed to the Google Groups
> "knitr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to knitr+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Daniel Fan

unread,
Feb 24, 2017, 3:22:24 PM2/24/17
to knitr, yingw...@gmail.com
Thanks, it works.

Yihui Xie於 2017年2月24日星期五 UTC-8上午12時21分05秒寫道:
Reply all
Reply to author
Forward
0 new messages