How can I calculate the percentage change within a group for multiple columns in R?
问题 I have a data frame with an ID column, a date column (12 months for each ID), and I have 23 numeric variables. I would like to obtain the percentage change by month within each ID. I am using the quantmod package in order to obtain the percent change. Here is an example with only three columns (for simplicity): ID Date V1 V2 V3 1 Jan 2 3 5 1 Feb 3 4 6 1 Mar 7 8 9 2 Jan 1 1 1 2 Feb 2 3 4 2 Mar 7 8 8 I tried to use dplyr and the summarise_each function, but that was unsuccessful. More