Multiple barplot using ggplot2

Sasak

According to this example I try to plot the following

Dataset is the following:

df <- structure(list(year = 2002:2005, work = c(1L, 2L, 3L, 2L), confid = c(8L, 
5L, 0L, 6L), jrs = c(0L, 3L, 4L, 5L)), .Names = c("year", "work", 
"confid", "jrs"), class = "data.frame", row.names = c(NA, -4L
))

The code in order to plot:

library(ggplot2)
library(reshape)
md <- melt(df, id=(c("year")))
temp.plot<-ggplot(data=md, aes(x=year, y=value, fill=variable) ) + 
    geom_bar()+ opts(axis.text.x=theme_text(angle=90)) + 
    opts(title = "Score Distribtion")

And the error I receive:

Error: could not find function "opts"

I tried to remove the opts() from graph but again I receive the same error.

What could it be the problem?

Marco Sandri

An updated version of your code using theme in substitution of opts:

df <- structure(list(year = 2002:2005, work = c(1L, 2L, 3L, 2L), confid = c(8L, 
5L, 0L, 6L), jrs = c(0L, 3L, 4L, 5L)), .Names = c("year", "work", 
"confid", "jrs"), class = "data.frame", row.names = c(NA, -4L
))

library(ggplot2)
library(reshape)
md <- melt(df, id=(c("year")))
temp.plot <- ggplot(data=md, aes(x=year, y=value, fill=variable) ) + 
    geom_bar(stat="identity")+ 
    theme(axis.text.x=element_text(angle=90))+ 
    ggtitle("Score Distribtion")

temp.plot

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

ggplot2 barplot labels using counts

Add text on top of a facet dodged barplot using ggplot2

Multiple line plot using ggplot2

ggplot2 stacked barplot: reorder bars by multiple dimensions

ggplot2 stacked barplot in R

Stacked barplot using ggplot2 - data visualisation

ggplot2 using facetwrap and multiple variables

How to plot a barplot using ggplot

How to plot multiple time series with a reverse barplot on the secondary axis using ggplot2?

Mantain order of dataframe for a stacked barplot using ggplot2

ggplot2 barplot

Multiple error bars add to columns in error on barplot in ggplot2

using ggplot2 to show multiple number columns in barplot?

Is there a way to have a barplot and a stacked barplot on the same graph using barplot or ggplot?

Show only top 3 entries and rest as "Others" in stacked barplot using ggplot2

Multiple facets using ggplot2

Reordering factors for a stacked barplot in ggplot2

Multiple legends for barplot fills in ggplot

5-dimensional stacked barplot using ggplot2

Add % to the barplot ggplot2

Is there a way to do a multiple stack barplot with ggplot2?

Barplot using ggplot2 for 4 variables

How do I create a non-stacked barplot with data labels using ggplot2 in R?

r - ggplot2 barplot of binary data

Cumulative percentage in a barplot with multiple value per group (ggplot2)

How to change colour for barplot in ggplot2 using viridis package?

How to plot a barplot using ggplot2

How to create a stacked barplot using Groups to determine Fill and X variable to determine Color (ggplot2)?

Add line with secondary axis to barplot using ggplot2