javascript - R string replacing part of javascript
问题描述
I'm sure this is a noob question but I couldn't figure out how you would insert a R string object inside a javascript. For example,
trackname <- "audiotrack1"
into
tag$script(var url = 'audioResources/' + trackname + '.wav')
Where I would want to replace the "trackname" with "audiotrack1". I'm sure paste0 isn't the best way to do this. What is the standard way to go about doing this?
Many thanks.
解决方案
This is not correct. You can do:
tags$script(HTML(sprintf("var url = 'audioResources/%s.wav'", trackname)))
推荐阅读
- ios - 在目标 c 中通过手势在图像上画线
- python - sklearn 中用于 10cv SVM 回归的分类(字符串)特征
- php - PHP 标头在 WordPress ajax 调用中不起作用
- mysql - 加入 3 个表并选择计数
- excel - 将多列数据拆分为行
- selenium - 如何在appium中上传文件以实现移动应用自动化?
- reporting-services - 需要将 Microstrategy 报告转换为 SSRS 平台的最佳实践或工具
- mongodb - mongodb $facet 未接受的结果
- python - 如何在 Pandas 中去除字符串列开头和结尾的标点符号
- mysql - Ejabberd Disco Itam 不来