user7193634 user7193634 - 17 days ago 11
R Question

Stacked barplot of small data set in R

I have a a file which contains two lists: with names in first column and numbers in secound column.

I would like to make a bar plot with names on x-axis and numbers on y-axis.

I used melt(mydata) and got a file with 3 columns: V1 (names) variable (V2) value (number)

Then I tried

ggplot(dat, aes(x = "V1", y= "value", fill = "variable")) + geom_bar(stat="identity")


The I got: Stacked barplot

Any ideas where I go wrong?

Answer

You're over complicating it:

ggplot(dat, aes(V1, value)) + geom_bar(stat = "identity")