我想转型c('1','2', 'text')
转换为只有一个元素的字符向量c('1','2', 'text')
.
我已经尝试过这个:
> quote(c('1','2', 'text'))
c("1", "2", "text")
but
> class(quote(c('1','2', 'text')))
[1] "call"
和这个:
> toString(quote(c('1','2', 'text')))
[1] "c, 1, 2, text"
这会删除所有标点符号(虽然我想保留完全相同的字符串)。
deparse
用于将表达式转换为字符串。
deparse(c('1','2', 'text'))
#[1] "c(\"1\", \"2\", \"text\")"
cat(deparse(c('1','2', 'text')))
#c("1", "2", "text")
gsub("\"", "'", deparse(c('1','2', 'text')))
#[1] "c('1', '2', 'text')"
deparse(quote(c('1','2', 'text')))
#[1] "c(\"1\", \"2\", \"text\")"
还看substitute
deparse(substitute(c(1L, 2L)))
#[1] "c(1L, 2L)"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)