[英]Convert markdown to json in R
Here are the steps I would like to execute: 以下是我要执行的步骤:
Eg. 例如。 markdown text file: 降价文本文件:
## This is a list
+ one
+ two
+ three
#### Do a thing
```coffee
points <- rnorm(10)
plot(points)
```
#### Do something else
![](someimage)
Steps 1 and 3 are easy, but step 2 is the one I don't get. 步骤1和3很容易,但步骤2是我没有得到的。 A call to rjson::toJSON
or RJSONIO::toJSON
doesn't format the output JSON correctly. 对rjson::toJSON
或RJSONIO::toJSON
调用不会正确格式化输出JSON。 Does anyone know of a way to do this. 有谁知道这样做的方法。 This README on github has an example of what seems like a nice markdown to JSON conversion. 这个关于github的README有一个看起来像JSON转换的好标记的例子。
rCharts has a couple of utility functions that can do this easily. rCharts有几个实用功能可以轻松完成。 I am assuming your Rmd file is saved as test.Rmd
. 我假设您的Rmd文件保存为test.Rmd
。 You can view the published gist here 您可以在此处查看已发布的要点
require(rCharts)
payload = create_gist('test.Rmd', description = 'Testing Md to Gist')
post_gist(payload, viewer = 'http://gist.github.com/')
Is this what you were looking for? 这是你在找什么?
UPDATE: If you want to update the gist you created, you can use the update_gist
function, and pass it the gist id. 更新:如果要更新您创建的要点,可以使用update_gist
函数,并将gist id传递给它。
update_gist(payload, id, viewer = 'http://gist.github.com/')
You can use options(github.username = ..., github.password = ...)
if you don't want to enter your username and password in your R console. 如果您不想在R控制台中输入用户名和密码,可以使用options(github.username = ..., github.password = ...)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.