r - 如何嵌套小标题
问题描述
我有一个这样的数据框:
players<-data.frame(
stringsAsFactors = FALSE,
seat = c("Seat 1","Seat 2","Seat 3",
"Seat 4","Seat 5","Seat 6"),
jugador = c("MSC1266","Cereghetti16",
"Trytopredict","klariti","P.H.F.17","FerzRu"),
stack = c("1.90 ", "2.03 ", "2 ", "2.60 ", "1.52 ", "3.99 "),
posicion = c("BU", "SB", "BB", "EP", "MP", "CO"),
hand = c("218755078355","218755078355",
"218755078355","218755078355","218755078355",
"218755078355")
)
我想将它嵌套在“手”列中,以便有一行,该列的所有值都在一个向量中。但是当我这样做时:
jugadores %>% nest(hand)
# A tibble: 6 x 5
seat jugador stack posicion data
<chr> <chr> <chr> <chr> <list>
1 Seat 1 MSC1266 "1.90 " BU <tibble [1 x 1]>
2 Seat 2 Cereghetti16 "2.03 " SB <tibble [1 x 1]>
3 Seat 3 Trytopredict "2 " BB <tibble [1 x 1]>
4 Seat 4 klariti "2.60 " EP <tibble [1 x 1]>
5 Seat 5 P.H.F.17 "1.52 " MP <tibble [1 x 1]>
6 Seat 6 FerzRu "3.99 " CO <tibble [1 x 1]>
Warning message:
All elements of `...` must be named.
Did you want `data = c(hand)`?
解决方案
players %>%
group_by(hand) %>%
nest()
或者
players %>%
group_nest(hand)
推荐阅读
- mysql - 如何使用nodejs从mysql中解码汉字
- java - 从嵌套的 java 对象中获取字段的所有值
- json - 如何在 apache nifi 中为 kafka 生产者指定密钥?
- azure - 在使用 terraform 在 Azure 中创建网络接口时,使用现有的子网详细信息而不是再次创建
- java - 如何在 Eclipse 中将标题文本或许可证标题添加到已经存在的 java 类中
- tensorflow - Tensorflow:如何转换为 tflite?
- android - 单击项目时将导航抽屉滚动到底部
- apache - Gentoo 安装 mod_proxy_balancer
- mac-address - 无法在 MacBook 中欺骗 MAC 地址
- rust - 为什么 map 和 map_err 捕获相同的变量?