-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprac12.R
33 lines (26 loc) · 781 Bytes
/
prac12.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
library(tidyverse)
library(dslabs)
data("gapminder")
#transformations
gapminder <- gapminder%>%
mutate(dollars_per_day = gdp/population/365)
past_year <- 1970
p <- gapminder %>%
filter(year == past_year & !is.na(gdp)) %>%
ggplot(aes(dollars_per_day)) +
geom_histogram(binwidth = 1,color='black')
#applying log transformation
q <- gapminder %>%
filter(year == past_year & !is.na(gdp)) %>%
ggplot(aes(log2(dollars_per_day))) +
geom_histogram(binwidth = 1,color='black')
#scale the axis
#not scaling the data is useful as we retain the original points
r <- gapminder %>%
filter(year == past_year & !is.na(gdp)) %>%
ggplot(aes(dollars_per_day)) +
geom_histogram(binwidth = 1,color='black')+
scale_x_continuous(trans = 'log2')
print(p)
print(q)
print(r)