My question is related with this one: Side-by-side bars in bar plot I am trying to do the same kind of thing, but I just don't get any data, the axis are filled in. But no visualised graph. I tried to remoddel the data in small steps, but it still did not worked out. I have no clue, why the data is not shown.
n<-15
data <- data.frame("number" = c(1:n),
"Nasal" = c(15.4, 13.5, 13.3, 12.4, 12.8,
13.5, 14.5, 13.9, 11.0, 15.0,
17.0, 13.8, 17.4, 16.5, 14.4),
"Endob" = c(16.5, 13.2, 13.6, 13.6, 14.0,
14.0, 16.0, 14.1, 11.5, 14.4,
16.0, 13.2, 16.6, 18.5, 14.5))
library(ggplot2)
method<-rep(c("Nasal","Endob"),each=n)
values<-c(data$Nasal, data$Endob)
patient<-factor(c(1:15))
data2<- data.frame(patient,method,values)
data2
ggplot(data2, aes(x=factor(patient), fill=method, y=values))
geom_bar(position ="dodge",stat="identity")
I think it runs fine, you just forgot the +
between ggplot
and geom_bar
.
ggplot(data2, aes(x=factor(patient), fill=method, y=values)) +
geom_bar(position ="dodge",stat="identity")