#data
set.seed (12345)
var <- rnorm(1000, 50,10)
group <- c(rep("A",100), rep("B",100), rep("C",100), rep("D",100), rep("E", 100))
dataf <- data.frame(var, group)
set.seed (12345)
var <- rnorm(1000, 50,10)
group <- c(rep("A",100), rep("B",100), rep("C",100), rep("D",100), rep("E", 100))
dataf <- data.frame(var, group)
#plot
require(lattice)
require(lattice)
# single
bwplot(var, xlab="y(units)",fill = "green4")
# grouped
bwplot(group ~var, data=dataf, xlab="y(units)", col = "blue", fill = heat.colors(5))
#fill user defined colors
mycol <- c("midnightblue", "darkseagreen", "yellow", "green3", "tan")
bwplot(group~var, data=dataf, xlab="y(units)", fill= mycol)
# using ggplot2:
require(ggplot2)
plot2 <- ggplot (dataf, aes (y = var, x= group, fill = group ))
plot2 + geom_boxplot()+theme_bw( )
require(ggplot2)
plot2 <- ggplot (dataf, aes (y = var, x= group, fill = group ))
plot2 + geom_boxplot()+theme_bw( )
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.