从 R 中的字符向量中删除引号 [英] Remove quotes from a character vector in R
本文介绍了从 R 中的字符向量中删除引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设你有一个字符向量:
Suppose you have a character vector:
char <- c("one", "two", "three")
当您引用索引值时,您会得到以下信息:
When you make reference to an index value, you get the following:
> char[1]
[1] "one"
如何从返回值中去掉引号以获得以下内容?
How can you strip off the quote marks from the return value to get the following?
[1] one
推荐答案
as.name(char[1])
会起作用,虽然我不确定你为什么真的想要这样做 - 引号不会被带入 paste
例如:
as.name(char[1])
will work, although I'm not sure why you'd ever really want to do this -- the quotes won't get carried over in a paste
for example:
> paste("I am counting to", char[1], char[2], char[3])
[1] "I am counting to one two three"
这篇关于从 R 中的字符向量中删除引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文