【发布时间】:2013-04-28 19:36:49
【问题描述】:
我有想要组合成向量的列列表。列元素可以是名称或字符串“0”。我想将具有名称的列元素列表放入一个名为df$keywords 的字符向量中。我在下面粘贴了一个示例数据框。我希望它变成
df$keywords[1,] 将是一个空向量
df$keywords[2,] 将是 (ACT Science, study skills, MCAT)
任何帮助将不胜感激
structure(list(V31 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = "0", class = "factor"), V32 = structure(c(1L,
2L, 4L, 5L, 7L, 8L, 6L, 5L, 3L, 3L), .Label = c("0", "ACT Science",
"English", "Microsoft PowerPoint", "physics", "proofreading",
"reading", "writing"), class = "factor"), V33 = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "0", class = "factor"),
V34 = structure(c(1L, 7L, 5L, 5L, 8L, 2L, 6L, 5L, 3L, 4L), .Label = c("0",
"geography", "Italian", "literature", "prealgebra", "SAT reading",
"study skills", "trigonometry"), class = "factor"), V35 = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "0", class = "factor"),
V36 = structure(c(1L, 3L, 4L, 4L, 7L, 2L, 6L, 4L, 5L, 5L), .Label = c("0",
"English", "MCAT", "precalculus", "proofreading", "SAT writing",
"writing"), class = "factor"), V37 = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "0", class = "factor"),
V38 = structure(c(1L, 1L, 5L, 5L, 2L, 1L, 4L, 5L, 3L, 6L), .Label = c("0",
"English", "GED", "physical science", "reading", "spelling"
), class = "factor")), .Names = c("V31", "V32", "V33", "V34",
"V35", "V36", "V37", "V38"), class = "data.frame", row.names = c(NA,
-10L))
【问题讨论】:
-
嗨,对不起,但这没有多大意义。您描述为输出的内容与示例数据不匹配。另外,您要将它们组合成
vector还是data.frame?为了清楚起见,请考虑修改您的问题。