Thanks in advance for your response.
I am trying to create a stacked bar plot from a csv file, and I have run into the following hiccup:
First I put the csv into a variable:
test <- read.csv(file=\"test4.csv\",sep=\",\",head=TRUE")
Then I try to create a bar plot using the following
barplot(test)
and I get the following error,
Error in barplot.default(test) : 'height' must be a vector or a matrix
so I try
barplot(t(test))
and it works but as expected the axis are switched, so I try
barplot(t(t(test)))
and it works, but I feel there must be a better solution than transposing the transposed.
The issue is that
read.csvoutputs a data frame andbarplotexpects either a vector or a matrix. Thebarplotfunction works when you transpose becauset()coerces data frames to matrices.If you either start with
or later on do
then you should be fine.