These exercises cover base plotting for Plotting in R.
Read in the data “timecourse.csv” as a data.frame and get a summary of column values
## Time Control1 Control2 Treatment1 Treatment2
## Min. : 0.0 Min. :2.000 Min. :3.000 Min. : 3.00 Min. : 4.0
## 1st Qu.: 2.5 1st Qu.:3.500 1st Qu.:3.500 1st Qu.: 7.00 1st Qu.: 8.5
## Median : 5.0 Median :5.000 Median :4.000 Median :12.00 Median :13.0
## Mean : 5.0 Mean :4.909 Mean :4.727 Mean :10.36 Mean :11.0
## 3rd Qu.: 7.5 3rd Qu.:6.500 3rd Qu.:6.000 3rd Qu.:14.50 3rd Qu.:14.0
## Max. :10.0 Max. :7.000 Max. :7.000 Max. :15.00 Max. :15.0
## Time Control1 Control2 Treatment1 Treatment2
## Min. : 0.0 Min. :2.000 Min. :3.000 Min. : 3.00 Min. : 4.0
## 1st Qu.: 2.5 1st Qu.:3.500 1st Qu.:3.500 1st Qu.: 7.00 1st Qu.: 8.5
## Median : 5.0 Median :5.000 Median :4.000 Median :12.00 Median :13.0
## Mean : 5.0 Mean :4.909 Mean :4.727 Mean :10.36 Mean :11.0
## 3rd Qu.: 7.5 3rd Qu.:6.500 3rd Qu.:6.000 3rd Qu.:14.50 3rd Qu.:14.0
## Max. :10.0 Max. :7.000 Max. :7.000 Max. :15.00 Max. :15.0
Produce a histogram of the values for control and treatment samples
Put these in the same plot with same X scale limits
Make a barplot of values in control sample 1 for every time point
Make a barplot of mean values in control and treatment samples side by side for every time point
par(mfrow=c(1,1))
controlMeans <- rowMeans(timeCourse[,c(2,3)])
treatmentMeans <- rowMeans(timeCourse[,c(4,5)])
meanTable <- rbind(controlMeans,treatmentMeans)
barplot(meanTable,names.arg = timeCourse[,1],xlab = "Time",beside=TRUE,col=c("blue","red"))
legend("topleft",legend = c("Control","Treatment"),fill=c("blue","red"))
Create a line graph showing control and treatment samples against time.
topOfY <- max(timeCourse[,-1])+3
plot(timeCourse[,2],type="o",xlab="Time",ylab="Score",pch=1,ylim=c(0,topOfY),col="blue")
lines(timeCourse[,3],pch=1,col="blue",type="o")
lines(timeCourse[,4],pch=1,col="red",type="o")
lines(timeCourse[,5],pch=1,col="red",type="o")
legend("topleft",legend = c("Control","Treatment"),col=c("blue","red"),lwd = 2)