It is often with the forest data that we have information about thinnings aggregated with the state of the stand after thinning. See example of a such situation
df <- data.frame(year = c(2001, 2002, 2003, 2004, 2005), vol = c(100, 120, 80, 160, 180), rem = c(0, 0, 60, 0, 0))
df
## year vol rem
## 1 2001 100 0
## 2 2002 120 0
## 3 2003 80 60
## 4 2004 160 0
## 5 2005 180 0
#so it is a stand that had been thinned 2003 and we have data about standing ba after thinning and removed ba
If we plot this we will recieve
Thus, my proposal is
#replicate the rows for each observation
df <- df[rep(seq_len(nrow(df)), each = 2), ]
df
## year vol rem
## 1 2001 100 0
## 1.1 2001 100 0
## 2 2002 120 0
## 2.1 2002 120 0
## 3 2003 80 60
## 3.1 2003 80 60
## 4 2004 160 0
## 4.1 2004 160 0
## 5 2005 180 0
## 5.1 2005 180 0
#and than calculate the total ba before thinning (odd rows 1, 3, 5, 7 ect)
#I use a loop but any other solution that will do this is valid ex. dplyr, data.table
for (i in seq(1, length(df$year), 2)){
df$vol[i] = df$vol[i] + df$rem[i]
}
#we get data frame like this
df
## year vol rem
## 1 2001 100 0
## 1.1 2001 100 0
## 2 2002 120 0
## 2.1 2002 120 0
## 3 2003 140 60
## 3.1 2003 80 60
## 4 2004 160 0
## 4.1 2004 160 0
## 5 2005 180 0
## 5.1 2005 180 0
Now we can plot the figure we want