首页 > 解决方案 > 按每行中的括号标题拆分和重新排列列

问题描述

所以,我有一些看起来像这样的数据:
当前数据样本

dput(df)
structure(list(Parties = structure(c(2L, 3L, 1L), .Label = c("City (Plaintiff) Doe, John (Defendant)", 
"John Doe Enterprises Inc (Plaintiff) Doe, John (Defendant) Does 1-5, John (Defendant)", 
"John Doe Properties LLC (Plaintiff) Doe, Jane (Defendant) Doe, Jane (Defendant)"
), class = "factor")), class = "data.frame", row.names = c(NA, 
-3L))

我希望把它分开,这样我就有几列原告和几列被告,就像这样(或类似的东西):

目标数据样本

但是我很难弄清楚我的 R 代码应该是什么样子。有什么想法吗?

标签: rstringdataframecharacter

解决方案


推荐阅读