install.packages("lattice") install.packages("ggplot2") library(lattice) library(ggplot2)
Use the https://vincentarelbundock.github.io/Rdatasets/datasets.html link to get a dataset, below is the Cardiac Data for Domestic dogs which is the one I used
data_from_file <- read.table(file.choose(),header=T,sep=",")[,2:3]
boxplot((lvp*100)~mvo,data_from_file, main="Cardiac Data for Domestic Dogs", xlab="mvo", ylab="Percent lvp", las=1, col=rainbow(6))
bwplot((lvp*100)~mvo, data=data_from_file, horizontal=FALSE, main="lvp Rate", xlab="mvo", ylab="Percent lvp", las=1, par.settings = list(box.rectangle = list(fill=rainbow(6))))
data_for_gg <- data_from_file data_for_gg$mvo <- as.factor(data_for_gg$mvo)
ggplot(data_for_gg, aes(x=mvo, y=lvp*100, fill=mvo)) + geom_boxplot() + labs(title="Cardiac Data for Domestic Dogs", x="mvo", y="Percent lvp") + theme_classic()