我有这样一个数据集:
structure(list(`Frequency
Percent` = c("car", "window", "ball",
"ups"), AI = c("2\n0.00", "3\n0.00", "1\n0.00", "2\n0.00"), BLK = c("0\n0.00",
"218\n0.29", "48\n0.06", "0\n0.00"), HIANIC = c("1\n0.00", "8\n0.01",
"4\n0.01", "0\n0.00"), NATRICAN = c("9\n0.01", "7\n0.01", "8\n0.01",
"0\n0.00"), UNK = c("15\n0.02", "83\n0.11", "36\n0.05", "0\n0.00"
), yy = c("111\n0.15", "897\n1.20", "756\n1.02", "1\n0.00")), class = "data.frame", row.names = c(NA,
-4L))
我如何用""拆分每行并删除n以生成两个新列?例如,car
和AI
单元格("2\n0.00"),我将在两个不同的列中有2和0.00。
5条答案
按热度按时间pokxtpni1#
一种方法是在
for
循环中使用tidyr::separate
:输出:
umuewwlo2#
使用
tidyr::separate_rows
和tidyr::pivot_wider
可以执行以下操作:m1m5dgzv3#
A * 底座 * 一个内衬:
或者添加一个类型转换器。
nkoocmlb4#
也有一种碱基R溶液:
结果是:
ztyzrc3y5#
我们可以使用
cSplit