我得到了一个数据框架,其中有一堆变量作为引号中的因子,比如
""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"))
提前谢谢!