I managed to get my result:
I loaded the stackedPlot () function from https://stat.ethz.ch/pipermail/r-help/2005-August/077475.html
Function (not mine, see link):
stackedPlot = function(data, time=NULL, col=1:length(data), ...) { if (is.null(time)) time = 1:length(data[[1]]); plot(0,0 , xlim = range(time) , ylim = c(0,max(rowSums(data))) , t="n" , ... ); for (i in length(data):1) {
Then I processed my data in a wide format. Then it worked!
wide = reshape(data, idvar="ThingAge", timevar="VisitWeek", direction="wide"); stackedPlot(wide);
source share