R markdown赋值js-variable

时间:2015-08-24 08:50:21

标签: r

我正在创建.rmd文件,如何将字符串分配到<script></script>代码段

```{r results='asis'}
 string<-"test"
```
<script>
var js_string = "......"
</script>

1 个答案:

答案 0 :(得分:3)

这对我有用:

---
title: "Untitled"
author: "Roman Luštrik"
date: "24. avgust 2015"
output: html_document
---

```{r results='asis'}
 string<-"test"
```
<script>
var js_string = `r dQuote(string)`
</script>

enter image description here