In tidyr, what criteria does the function `gather` use to map a dataframe from wide to long?
- 阅读更多 关于 In tidyr, what criteria does the function `gather` use to map a dataframe from wide to long?
I'm trying to figure out the arguments for gather in the tidyr package. I looked at the documentation, and the syntax looks like: gather(data, key, value, ..., na.rm = FALSE, convert = FALSE) There is an example in the help files: stocks <- data.frame( time = as.Date('2009-01-01') + 0:9, X = rnorm(10, 0, 1), Y = rnorm(10, 0, 2), Z = rnorm(10, 0, 4) ) gather(stocks, stock, price, -time) I'm curious about the last line: gather(stocks, stock, price, -time) Here, stocks is clearly the data we want to modify, which is fine. So I can read that stock and price are arguments to a key value pair -- but