我有以下情况,列
我想知道如何将这些值拆分,使每个订单成为一个新的列。最好像dplyr一样提供解决方案。我尝试过使用tidyr中的unnest或separate函数来解决问题,但没有成功。
谢谢!
以下是数据:
power_dbm0
的值是一个列表。所有元素都是长度为11的列表。# A tibble: 10 x 2
real_pat power_dbm0
<chr> <list>
1 am <dbl [11]>
2 fax <dbl [11]>
3 fp <dbl [11]>
4 fpw <dbl [11]>
我想知道如何将这些值拆分,使每个订单成为一个新的列。最好像dplyr一样提供解决方案。我尝试过使用tidyr中的unnest或separate函数来解决问题,但没有成功。
谢谢!
以下是数据:
structure(list(real_pat = c("am", "fax", "fp", "fpw"), power_dbm0 = list(
structure(c(0.0142857142857143, 0.0742857142857143, 0.111428571428571,
0.138571428571429, 0.208571428571429, 0.278571428571429,
0.368571428571429, 0.508571428571429, 0.648571428571429,
0.771428571428571, 0.871428571428571), .Names = c("0%", "10%",
"20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"
)), structure(c(0.342857142857143, 0.342857142857143, 0.342857142857143,
0.342857142857143, 0.342857142857143, 0.342857142857143,
0.342857142857143, 0.342857142857143, 0.342857142857143,
0.342857142857143, 0.342857142857143), .Names = c("0%", "10%",
"20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"
)), structure(c(0.0142857142857143, 0.622857142857143, 0.808571428571429,
0.851428571428571, 0.857142857142857, 0.871428571428571,
0.874285714285714, 0.885714285714286, 0.894285714285714,
0.911428571428571, 0.914285714285714), .Names = c("0%", "10%",
"20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"
)), structure(c(0.514285714285714, 0.514285714285714, 0.514285714285714,
0.514285714285714, 0.514285714285714, 0.514285714285714,
0.514285714285714, 0.514285714285714, 0.514285714285714,
0.514285714285714, 0.514285714285714), .Names = c("0%", "10%",
"20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"
)))), .Names = c("real_pat", "power_dbm0"), row.names = c(NA,
-4L), class = c("tbl_df", "tbl", "data.frame"))
dput
显示示例以及您期望的输出。不清楚每个列表元素中包含什么。 - akrundf1 %>% mutate(power_dbm0 = map(power_dbm0, as_tibble)) %>% unnest
吗? - akrun