1、gather()
函数
gather(data, key, value, ...) where data is the dataframe you are working with. key is the name of the key column to create. value is the name of the value column to create. ... is a way to specify what columns to gather from.
功能:
举例:以下是table4
table4 %>% gather("year", "cases", 2:3)
优秀参考:
https://tidyr.tidyverse.org/reference/gather.html
http://statseducation.com/Introduction-to-R/modules/tidy%20data/gather/