【发布时间】:2021-12-22 09:17:03
【问题描述】:
我有一个 data.frame,我想将 IV 列分隔成单独的行,以用于以逗号“”分隔的每一段文本,不包括括号之间以逗号为特征的那些文本段,例如",text(字符串,字符串,字符串),".
当前数据示例:
structure(list(Article.Title = "Random title",
Sample = "Sample information",
IV = "Union voice, HRM practices (participation, teams, incentives, development, recruitment), implict contracts, Crisis impact, dominant individual or family owner, no dominant individual or family owner, market growth, no market growth,",
Moderator = NA_character_, Mediator = NA_character_, DV = "Performance"), row.names = c(NA,
-1L), class = c("tbl_df", "tbl", "data.frame"))
预期结果:
structure(list(Article.Title = c("Random title", "Random title",
"Random title", "Random title", "Random title", "Random title",
"Random title", "Random title"), Sample = c("Sample information",
"Sample information", "Sample information", "Sample information",
"Sample information", "Sample information", "Sample information",
"Sample information"), IV = c("Union voice", "HRM practices (participation, teams, incentives, development, recruitment)",
"implict contracts", "Crisis impact", "dominant individual or family owner",
"no dominant individual or family owner", "market growth", "no market growth"
), Moderator = c("NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA"
), Mediator = c("NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA"
), DV = c("Performance", "Performance", "Performance", "Performance",
"Performance", "Performance", "Performance", "Performance")), class = "data.frame", row.names = c(NA,
-8L))
【问题讨论】:
标签: r