Hello,
I have wrote the following code to plot my graph, but there is an error of "Error: Cannot add ggproto objects together. Did you forget to add this object to a ggplot object?"
here is part of my data:
No. proportion time column group
1 0.82600175 t1 c1 g1
2 0.1702305 t1 c1 g1
3 0.082397 t2 c1 g1
4 0.086999 t2 c1 g1
1 0.17719225 t1 c2 g2
2 0.11405925 t1 c2 g2
3 0.07877325 t2 c2 g2
4 0.0535725 t2 c2 g2
1 0.0357865 t1 c3 g3
2 0.03244875 t1 c3 g3
3 0.08053775 t2 c3 g3
4 0.05981925 t2 c3 g3
1 0.121641 t1 c4 g4
2 0.026107 t1 c4 g4
3 0.0606535 t2 c4 g4
4 0.0266555 t2 c4 g4
code:
library(ggplot2)
library(dplyr)
library(tidyr)
library(tidyverse)
require(gridExtra)
file1<-read.csv("H:/prop.csv")
colm=c("t1"="red","t2"="blue","t3"="coral4","t4"="orange")
labels1 <- c("column 1","column 2","column 3","column 4")
title<-"Column"
b1<-ggplot(file1, aes(x=No.,colour=column))+
geom_line(aes(y = proportion))+
xlab("Number")+ylab("proportion")+
scale_color_manual(values =c("t1"="red","t2"="blue","t3"="coral4","t4"="orange"), labels=labels1 ,name="Time")+
guides(colour = guide_legend(title=title))+
labs(title="Column 1")+ theme(plot.title=element_text(size=12,hjust=0.5,face="bold"))+
scale_x_discrete(position = "top")+ facet_grid(vars(time), vars(group))
b1
Would you help me fix this problem please?
Thanks