##Dates & Times
dta<-read.table("C:/Users/ncku/Documents/tw_to_us.txt",header = 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)
## Warning: package 'ggplot2' was built under R version 3.4.4
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")
##Maps
library(leaflet)
## Warning: package 'leaflet' was built under R version 3.4.4
m <- leaflet() %>%
addTiles() %>%
addMarkers(lng =120.200556, lat =22.991594, popup = "樂饌殿") %>%
addMarkers(lng =120.201716, lat =22.986398, popup = "閃 SHEM") %>%
addMarkers(lng =120.195450, lat =22.986644, popup = "魁")
m
##the Internet
library(rvest)
## Warning: package 'rvest' was built under R version 3.4.4
## Loading required package: xml2
## Warning: package 'xml2' was built under R version 3.4.4
# Mission: Impossible - Rogue Nation
fL <- "https://www.imdb.com/title/tt2381249/?ref_=fn_al_tt_1"
# extract content of web page
film_ts <- read_html(fL)
# extract rating
film_ts %>%
html_node("strong span") %>%
html_text() %>%
as.numeric()
## [1] 7.4
# extract cast
film_ts %>%
html_nodes("#titleCast .itemprop span") %>%
html_text()
## [1] "Tom Cruise" "Jeremy Renner" "Simon Pegg"
## [4] "Rebecca Ferguson" "Ving Rhames" "Sean Harris"
## [7] "Simon McBurney" "Jingchu Zhang" "Tom Hollander"
## [10] "Jens Hulten" "Alec Baldwin" "Mateo Rufino"
## [13] "Fernando Abadie" "Alec Utgoff" "Hermione Corfield"