【发布时间】:2018-11-06 08:38:00
【问题描述】:
我有一个数据框可以处理,我有一堆变量作为引号中的因素,例如""x1""。
str(df) 给了我这样的东西:
$ x : Factor w/ 10 Levels "\"\"x1\"\"",..: 1 7 9 ...
我试图用gsub() 函数去掉引号,但是没有用。可能是因为我不知道要插入什么作为模式?如果有人能解决这个难题,如果"\"\"x1\"\"" 是解决这个问题的方法,也许可以向我解释一下?
数据框的示例如下所示:
structure(list(Sent = structure(c(2L, 2L, 2L, 2L, 2L), .Label = c("\"\"Opted out\"\"",
"\"\"Yes\"\""), class = "factor"), Responded = structure(c(2L,
2L, 2L, 2L, 2L), .Label = c("\"\"Complete\"\"", "\"\"No\"\"",
"\"\"Partial\"\""), class = "factor")), row.names = c(NA, -5L
), class = c("tbl_df", "tbl", "data.frame"), .Names = c("Sent",
"Responded"))
提前致谢!
【问题讨论】:
-
如果能提供可重现的例子就好了