#reproducable example
ThreeSpecies<-structure(list(Species = c("Pig", "Pig", "Pig", "Pig", "Pig",
"Human", "Human", "Human", "Human", "Human", "Mouse", "Mouse",
"Mouse", "Mouse", "Mouse"), Stage = structure(c(1L, 2L, 3L, 4L,
5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), .Label = c("2 cell",
"4 cell", "8 cell", "Morula", "Blastocyst"), class = "factor"),
Time of Appearance (hpi) and Standard Deviation
= c("18.6 ± 2.15",
"38.8 ± 13.50", "78.6 ± 4.71", "101.1 ± 2.48", "133 ± 10.00",
"27.2 ± 3.6", "40 ± 5.4", "62.1 ± 9.8", "93.9 ± 9.8", "105.2 ± 6.3",
"7.2 ± 2.6", "30.7 ±3.7", "42.1 ±5.1", "54.6 ± 4.5", "68 ±4.7"
), Percentage of Time (%)
= c(13.984962406, 29.1729323308,
59.098, 76.015037594, 100, 25.855513308, 38.23, 59.03, 89.2585551331,
100, 10.5882352941, 45.1470588235, 61.9117647059, 80.2941176471,
100)), row.names = c(NA, -15L), class = c("tbl_df", "tbl",
"data.frame"))
#Change order of factor levels as they are being used in numerical and then alphabetical order
ThreeSpecies$Stage <- factor(ThreeSpecies$Stage, levels = c("2 cell", "4 cell", "8 cell","Morula","Blastocyst"))
#load this
library(ggplot2)
plot graph
ggplot(ThreeSpecies,aes(Species, 'Percentage of Time (%)' , fill=Stage),stat="identity",position_stack(vjust=1))+ geom_bar() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + scale_y_continuous(labels = scales::percent_format(scale = 100))+ylab("Percentage of time to blastocyst(%)")+xlab("Species")+ guides(fill=guide_legend("Stage"))
Error: Discrete value supplied to continuous scale
The problem is the error message and f in the percent stacked bar chart or each species it needs to be scaled to 100% ( i have calculated the percentages of time spent at each stage in the three species myself.) but i when i orginally plotted this is was scaled to 30%
what solution can i do for the error message and the graph