Exercise1
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
## Time difference of 251 days
Exercise2
## 'data.frame': 24 obs. of 2 variables:
## $ Hour : num 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 ...
## $ Calls: int 1080 910 770 780 380 390 200 300 275 395 ...
| 0.5 |
1080 |
| 1.5 |
910 |
| 2.5 |
770 |
| 3.5 |
780 |
| 4.5 |
380 |
| 5.5 |
390 |
library(ggplot2)
dta2$Hour <- as.integer((dta2$Hour))
ggplot(data= dta2, aes(x= Hour, y= Calls))+
geom_bar(stat = "identity", fill="cyan", color="gray", alpha=.2)+
geom_abline(intercept = mean(dta2$Calls), slope=0, color="pink")+
scale_x_time(breaks = 0:23 - .5,
labels = c(0, rep('', 4), 5, rep('', 4), 10, rep('', 4),
15, rep('', 4), 20, rep('', 3)))+
coord_polar(theta = 'x', start = -pi/24)+
theme_bw()+
theme(panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_blank())

Exercise3
## ─ Attaching packages ────── tidyverse 1.3.0 ─
## ✓ tibble 2.1.3 ✓ dplyr 0.8.5
## ✓ tidyr 1.0.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ✓ purrr 0.3.3
## ─ Conflicts ─────── tidyverse_conflicts() ─
## x lubridate::as.difftime() masks base::as.difftime()
## x lubridate::date() masks base::date()
## x dplyr::filter() masks stats::filter()
## x lubridate::intersect() masks base::intersect()
## x dplyr::lag() masks stats::lag()
## x lubridate::setdiff() masks base::setdiff()
## x lubridate::union() masks base::union()
names(data) <- c("weekdays", "Freq")
ggplot(data, aes(x=weekdays, y=Freq)) +
geom_segment( aes(x=weekdays, xend=weekdays, y=0, yend=Freq)) +
geom_point( size=5, color="yellow", fill=alpha("black", 0.3), alpha=0.7, shape=21, stroke=2)

Erxercise4
## 'data.frame': 29 obs. of 2 variables:
## $ Birth : num 23 22.1 20.6 19.6 18 15.9 16 17.2 15.7 16.6 ...
## $ Entrance: int NA NA NA NA NA NA NA NA NA NA ...
## Birth Entrance
## Min. : 8.30 Min. :44.00
## 1st Qu.:11.00 1st Qu.:59.50
## Median :15.30 Median :70.50
## Mean :14.41 Mean :72.25
## 3rd Qu.:16.00 3rd Qu.:89.50
## Max. :23.00 Max. :97.00
## NA's :13
library(ggplot2)
ggplot(data=dta4)+
geom_point(data=dta4, aes(x=Year, y=Birth),pch=1) +
scale_x_continuous(name="Year", breaks=seq(1980, 2010, 5))+
scale_y_continuous(name= "Birth rate(0.1%)", limits=c(0, 60), breaks=seq(0, 60, 10),
sec.axis=sec_axis(~.+40, breaks = seq(40, 100, 10), name="Acceptance rate(%)")) +
geom_point(data=dta4, aes(x=Year, y= College),pch=19) +
guides(fill=T)
## Warning: Removed 22 rows containing missing values (geom_point).
