Description Usage Arguments Value Examples
cuminyear calculates an accumulated variation in year of a index. Data must be start in january, use start to set this, if you data don't start in january and you need use this values, consider complete the previous months with 0.
1 |
data |
a dataframe |
coldate |
number of date column |
colnum |
number of values column |
start |
number of start row |
Return a dataframe.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | v=data.frame(
"Date"=c(seq.Date(as.Date("2018-01-01"),as.Date("2019-12-01"),by='month'))
,"Value"=c(rep(2,6),rep(3,6),rep(1,6),rep(5,6)))
cuminyear(v,coldate=1,colnum=2)
v=data.frame(
"Date"=c(seq.Date(as.Date("2018-06-01"),as.Date("2019-12-01"),by='month'))
,"Value"=c(rep(3,7),rep(1,6),rep(5,6)))
#this case, we can start in january 2019
cuminyear(v,coldate=1,colnum=2,start=8)
#or if we need the previous values i can complete january 2018 to may 2018 with 0.
v1=data.frame(Date=c(seq.Date(as.Date("2018-01-01"),as.Date("2018-05-01"),by='month')),
"Value"=c(rep(0,5)))
v=rbind(v1,v)
cuminyear(v,coldate=1,colnum=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.