tctcab 替你把新函数用法写了 😀, 虽然对咱们母语非英语者来说,函数名字影响可忽略不计,并且gather()
和spread()
也不会被移除。但是,以后只会更新pivot_wide()
和pivot_long()
的功能,所以还是用新函数吧
New pivot_longer() and pivot_wider() provide modern alternatives to spread() and gather(). They have been carefully redesigned to be easier to learn and remember, and include many new features. spread() and gather() won’t go away, but they’ve been retired which means that they’re no longer under active development.
dat1 <- data.frame(a = 1, b = 2, c = 3)
tidyr::pivot_longer(dat1, tidyselect::everything(), names_to = "rowname", values_to = "V1")
#> # A tibble: 3 x 2
#> rowname V1
#> <chr> <dbl>
#> 1 a 1
#> 2 b 2
#> 3 c 3
<sup>Created on 2019-09-15 by the reprex package (v0.3.0)</sup>