Data science enhances people’s decision making. Doctors and researchers are making critical decisions every day. Therefore, it is absolutely necessary for those people to have some basic knowledge of data science. This series aims to help people that are around medical field to enhance their data science skills.
We will work with a health related database the famous “Pima Indians Diabetes Database”. It was generously donated by Vincent Sigillito from Johns Hopkins University. Please find further information regarding the dataset here.
This is the first part of the series, it is going to be about data display.
Before proceeding, it might be helpful to look over the help pages for the table
, pie
, geom_bar
, coord_polar
, barplot
, stripchart
, geom_jitter
, density
, geom_density
, hist
, geom_histogram
, boxplot
, geom_boxplot
, qqnorm
, qqline
, geom_point
, plot
, qqline
, geom_point
.
You also may need to load the ggplot2
library.
install.packages('ggplot2')
library(ggplot2)
Please run the code below in order to load the data set and transform it into a proper data frame format:
url <- "https://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data"
data <- read.table(url, fileEncoding="UTF-8", sep=",")
names <- c('preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class')
colnames(data) <- names
Answers to the exercises are available here.
If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.
Exercise 1
Create a frequency table of the class
variable.
Exercise 2
data$class.fac <- factor(data[['class']],levels=c(0,1), labels= c("Negative","Positive"))
Create a pie chart of the class.fac
variable.
Exercise 3
Create a bar plot for the age
variable.
Exercise 4
Create a strip chart for the mass
against class.fac
.
Exercise 5
Create a density plot for the preg
variable.
Exercise 6
Create a histogram for the preg
variable.
Exercise 7
Create a boxplot for the age
against class.fac
.
Exercise 8
Create a normal QQ plot and a line which passes through the first and third quartiles.
Exercise 9
Create a scatter plot for the variables age
against the mass
variable .
Exercise 10
Create scatter plots for every variable of the data set against every variable of the data set on a single window.
hint: it is quite simple, don’t overthink about it.
Exercise 8 -> you didn’t mention for which variable normal QQ plot need to be created.
Love the lesson!
I’m a newbie, so I could be wrong but the code above has:
install.packages(‘ggplot2’)
library(ggplot)
Did you instead mean?
install.packages(‘ggplot2’)
library(ggplot2)
Thanks! Again, nice tutorial. – Mike Davis
Hello Mike! Thanks for the good words,
You are absolutely right !
Sorry for the delayed reply but I had some log in issues.
Cheers!