r - list inside string to list in R
问题描述
I have a string:
"list(id = '1001', status = c('xyz', 'abc', 'def', 'jkl'))"
I want to convert it to:
list(id = '1001', status = c('xyz', 'abc', 'def', 'jkl'))
Any help would be greatly appreciated.
解决方案
We can just do eval(parse
out <- eval(parse(text = "list(id = '1001', status = c('xyz', 'abc', 'def', 'jkl'))"))
-output
out
$id
[1] "1001"
$status
[1] "xyz" "abc" "def" "jkl"
With dput
, can get the structure
dput(out)
list(id = "1001", status = c("xyz", "abc", "def", "jkl"))
推荐阅读
- windows - 在 Windows Batch 中迭代键值对
- ruby-on-rails - Ruby 中的 Phusion Passenger 独立 Web 服务器 - Gem 加载错误
- java - hibernate + jersey2 + Json + blob 图像
- javascript - 移除 HTML 元素周围的奇怪边框
- python - conda 相当于 pip install
- python - 授权失败,因为服务器遇到了阻止其完成请求的意外情况
- cloudflare - 即使添加 cf 名称服务器,Cloudflare 也不会缓存
- c# - 如何自动生成具有 3 到 16 个顶点的原始网格?
- html - 如何在哈巴狗循环中回显一些 HTML?
- webpack - 在 Laravel Mix 中使用提取文本 Webpack 插件