You are on page 1of 2

student <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,

22, 23, 24, 25, 26, 27, 28,


29, 30)

sex <- c("female", "female", "female", "male", "male", "female", "female", "male", "male", "female",
"male", "male", "female", "male", "female", "female", "male", "female", "male", "female", "male",
"female", "male", "female", "male", "male", "male", "female", "male", "female")

parental.level.education <- c("bachelor' degree", "some college", "master's degree", "associate's


degree", "some college", "associate's degree", "some college", "some college", "high school", "high
school", "associate's degree", "associate's degree", "high school", "some college", "master's degree",
"some high school", "high school", "some high school", "master's degree", "associate's degree", "high
school", "some college", "some college", "some high school", "bachelor's degree", "master's degree",
"some college", "bachelor's degree", "high school", "master's degree")

lunch <- c("standard", "standard", "standard","free/reduced", "standard", "standard", "standard",


"free/reduced", "free/reduced", "free/reduced", "standard", "standard", "standard","standard",
"standard", "standard", "standard", "free/reduced", "free/reduced", "free/reduced", "standard",
"free/reduced", "standard", "standard", "free/reduced", "free/reduced", "standard", "standard",
"standard", "standard")

test.preparation.course <- c("none", "completed", "none", "none", "none", "none", "completed",


"none", "completed", "none", "none", "none", "none", "compeleted", "none", "none", "none", "none",
"completed", "none", "none", "completed", "none", "none", "completed", "none", "none", "none",
"none", "none")

math.score <- c(72, 69, 90, 47, 76, 71, 88, 40, 64, 38, 58, 40, 65, 78, 50, 69, 88, 18, 46, 54, 66, 65, 44, 69,
74, 73, 69, 67, 70, 62)

reading.score <- c(72, 90, 95, 57, 78, 83, 95, 43, 64, 60, 54, 52, 81, 72, 53, 75, 89, 32, 42, 58, 69, 75, 54,
73, 71, 74, 54, 69, 70, 70)

writing.score <- c(74, 88, 93, 44, 75, 78, 92, 39, 67, 50, 52, 43, 73, 70, 58, 78, 86, 28, 46, 61, 63, 70, 53,
73, 80, 72, 55, 75, 65, 75)

student <- data.frame(sex, parental.level.education, lunch, test.preparation.course, math.score,


reading.score, writing.score)

sex.table <- table(student$sex)

parental.level.education <- table(student$parental.level.education)

#Creating a pie chart for sex

pie(sex.table)

colors.pie <-c("Gray", "Red")

pie(sex.table, col=colors.pie)
#Creating a Bar Graph for parental.level.education

colors.bar <- c("blue", "skyblue", "yellow", "green", "red", "gray")

barplot(parental.level.education, col=colors.bar)

You might also like