set.seed(100)
data1 <- rpois(1000, lambda = 2)
set.seed(100)
data2 <- rpois(1000, lambda = 10)
df <- data.frame(seq1 = data1, seq2 = data2)
rownames(df) <- paste(rep('s',1000), 1:1000,sep = '_')
head(df)
## seq1 seq2
## s_1 1 8
## s_2 1 10
## s_3 2 9
## s_4 0 12
## s_5 2 10
## s_6 2 11
boxplot(df$seq1, df$seq2)
boxplot(df$seq1, df$seq2, ylab = 'Reads_count', las = 1,
names = c('s1', 's2'))
boxplot(df$seq1, df$seq2, ylab = 'Reads_count', las = 1,
names = c('s1', 's2'), col = c('red', 'navy'), ##adding the color
boxlty = c(0,0),## removing the border of box
medcol = c('white', 'white')
)
library(ggplot2) #loding the package
data(airquality) #loading the available data
head(airquality)
## Ozone Solar.R Wind Temp Month Day
## 1 41 190 7.4 67 5 1
## 2 36 118 8.0 72 5 2
## 3 12 149 12.6 74 5 3
## 4 18 313 11.5 62 5 4
## 5 NA NA 14.3 56 5 5
## 6 28 NA 14.9 66 5 6
aq <- airquality[ !is.na(airquality$Ozone) ,] #removing the missing data for Ozone variable
##draw the boxplot from ggplot2
aq$Month <- as.factor(aq$Month)
p10 <- ggplot(aq, aes(x = Month, y = Ozone)) +
geom_boxplot()
p10
##adding the color for each box
p10 <- ggplot(aq, aes(x = Month, y = Ozone)) +
geom_boxplot(fill = c('red','gold', 'navy', 'forestgreen', 'purple')) +
scale_y_continuous(name = 'Mean ozone in parts per billion', ## add the y asis name
breaks = seq(0,175,25), # the points at which tick-marks are to be drawn
limits = c(0,175)) #the minmum and maxmum of y-axis
p10
boxplot(aq$Ozone[aq$Month == 5],
aq$Ozone[aq$Month == 6],
aq$Ozone[aq$Month == 7],
aq$Ozone[aq$Month == 8],
aq$Ozone[aq$Month == 9],
col = c('red','gold', 'navy', 'forestgreen', 'purple'),
medcol = rep('white', 5),whisklty = 1,
boxlty = rep(0,5), names = c('May', 'Jun', 'July', 'Aug', 'Sep'),
ylab = 'Mean ozone in parts per billion',
las = 1)