#install.packages("rvest", dependencies = TRUE)
#
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
#Innocent Husbands by Leo McCarey
fL <- "https://www.imdb.com/title/tt0015948/"
# extract content of web page
film_ts <- read_html(fL)
# extract rating
film_ts %>%
html_node("strong span") %>%
html_text() %>%
as.numeric()
## [1] 6.9
# extract cast
film_ts %>%
html_nodes("#titleCast .itemprop span") %>%
html_text()
## [1] "Charley Chase" "Katherine Grant" "Jane Sherman"
## [4] "Lucien Littlefield" "James Finlayson" "William Gillespie"
## [7] "Kay Deslys"
library(leaflet)
## Warning: package 'leaflet' was built under R version 3.4.4
m <- leaflet() %>%
addTiles() %>%
addMarkers(lng = 120.2329291, lat = 23.0029567, popup = "石頭燒肉")
m
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.4.4
dta3<-read.table("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)
dta3<-data.frame(dta3,year)
knitr::kable(head(dta3))
| V1 | year |
|---|---|
| 3637 | 1950 |
| 2553 | 1955 |
| 4564 | 1960 |
| 6780 | 1965 |
| 12029 | 1970 |
| 12250 | 1975 |
ggplot(dta3,aes(x=year,y=V1)) + geom_line(lwd = rel(1.2)) +
labs(x="Year",y="Number of students") +
geom_vline(xintercept = c(1995), linetype = "dotted")
##赴美留學的人數在1995有下降的趨勢