I've looked at the similar questions on here regarding stacked bar plots in R, but I'm still not having any luck.
I have created the following data frame:
A B C D E F G
1 480 780 431 295 670 360 190
2 720 350 377 255 340 615 345
3 460 480 179 560 60 735 1260
4 220 240 876 789 820 100 75
A:G represents the x-axis and the y-axis would be duration (seconds). How would I go about stacking the following data in R?
Thank you very much in advance for your time and help.
The dataset:
dat <- read.table(text = "A B C D E F G
1 480 780 431 295 670 360 190
2 720 350 377 255 340 615 345
3 460 480 179 560 60 735 1260
4 220 240 876 789 820 100 75", header = TRUE)
Now you can convert the data frame into a matrix and use the barplot
function.
barplot(as.matrix(dat))