pacman::p_load(tidyverse, gridExtra, grid, png, padr, 
               ggridges, ggalt, lattice, scales, lubridate)
theme_set(theme_bw())

###Dates & Times

dta <- read.table("C:/Users/ncku/Documents/twtous.txt", h = F)

year<-c(1950,1955,1960,1965,1970,1975,1980,1985,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004)

dta<-data.frame(dta,year)

knitr::kable(head(dta))
V1 year
3637 1950
2553 1955
4564 1960
6780 1965
12029 1970
12250 1975
library(ggplot2)
ggplot(dta,aes(x=year,y=V1)) + geom_line(lwd = rel(1.2)) +
  labs(x="Year",y="Number of students") +
  geom_vline(xintercept = c(1990), linetype = "dotted")

pacman::p_load(tidyverse, RJSONIO, WDI, sp, maps,
               mapdata, maptools, ggmap, ggvis,
               micromap, micromapST,
               choroplethr, choroplethrMaps, choroplethrAdmin1,
               rworldmap, RgoogleMaps, rgeos, raster, googleVis, 
               rgdal, RColorBrewer, countrycode, classInt, 
               lattice, scales, lubridate, png, grid)
theme_set(theme_minimal())

###Maps

library(leaflet)
## Warning: package 'leaflet' was built under R version 3.4.4
m <- leaflet() %>%
 addTiles() %>%
 addMarkers(lng = 120.210753, lat = 23.005130, popup = "KEMMA雞蛋糕")%>%
 addMarkers(lng = 120.219012, lat = 22.995950, popup = "小紅帽雞蛋糕")%>%
 addMarkers(lng = 120.208311, lat = 22.999618, popup = "小豫雞蛋糕")
m

###R & the Internet

library(rvest)
## Loading required package: xml2
## 
## Attaching package: 'rvest'
## The following object is masked from 'package:XML':
## 
##     xml
## The following object is masked from 'package:purrr':
## 
##     pluck
## The following object is masked from 'package:readr':
## 
##     guess_encoding
# Black Panther
fL <- "https://www.imdb.com/title/tt1825683/"

# extract content of web page
film_ts <- read_html(fL)

# extract rating
film_ts %>%
 html_node("strong span") %>%
 html_text() %>%
 as.numeric()
## [1] 7.6
# extract cast
film_ts %>%
 html_nodes("#titleCast .itemprop span") %>%
 html_text()
##  [1] "Chadwick Boseman"  "Michael B. Jordan" "Lupita Nyong'o"   
##  [4] "Danai Gurira"      "Martin Freeman"    "Daniel Kaluuya"   
##  [7] "Letitia Wright"    "Winston Duke"      "Sterling K. Brown"
## [10] "Angela Bassett"    "Forest Whitaker"   "Andy Serkis"      
## [13] "Florence Kasumba"  "John Kani"         "David S. Lee"