-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ # 4.R
38 lines (26 loc) · 1.06 KB
/
Q # 4.R
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
31
32
33
34
35
36
37
38
# Rao Muhammad Rafay
# P200636
# Q-4
# box plots for population, income, and area for states
# using state data set
# loading data set
data(state)
# for population and income we have to take state.x77
data = state.x77
# as data/state.x77 is an atomic vector so we will be converting this to recursive for ease of work
atmvec_data = as.data.frame.matrix(data)
# storing population and income data
pop = atmvec_data$Population
inc = atmvec_data$Income
# for area
area = state.area
# plotting box plots
# for Population
boxplot(pop, main = "Boxplot for Population", ylab = "Population")
# for Income (limiting y axis for better illustration)
boxplot(pop, main = "Boxplot for Income", ylab = "Income", ylim = c(0, 6400))
# for area
boxplot(pop, main = "Boxplot for Area", ylab = "Area")
# for grouped box plots (Population, Income, Area)
# in this the frequency will be very high as max value for area is high as well
boxplot(pop, inc, area, main = "Grouped Box Plot", xlab = "Population, Income, Area (respectively)", ylab = "Frequency")