Stacked barplot for only one categorical variable in R

Using a barplot horizontally in R can sometimes be a bit tricky. This is what we want to achieve: For a vector, it shows the bars next to each other, for a matrix it stacks. That’s how it’s documented, ...