Question 6

pacman::p_load(robotstxt, rvest)

Step 1: Read the HTML document- webpage

paths_allowed("https://www.imdb.com/title/tt7235466/fullcredits?ref_=tt_cl_sm")
##  www.imdb.com
## [1] TRUE
imdb_html <- read_html("https://www.imdb.com/title/tt7235466/fullcredits?ref_=tt_cl_sm")

Step 2: Select the HTML elements

table_html <- html_elements(imdb_html, "table")
table_html
## {xml_nodeset (30)}
##  [1] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
##  [2] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
##  [3] <table class="cast_list">\n<tr><td colspan="4" class="castlist_label"></ ...
##  [4] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
##  [5] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
##  [6] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
##  [7] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
##  [8] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
##  [9] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [10] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [11] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [12] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [13] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [14] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [15] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [16] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [17] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [18] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [19] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## [20] <table class="simpleTable simpleCreditsTable">\n<colgroup>\n<col class=" ...
## ...

Step 3: Parse the html table into dataframe

table_list <- html_table(table_html[[3]])
cast <- table_list [[3]]
cast
##    [1] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##   [13] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##   [25] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##   [37] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##   [49] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##   [61] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##   [73] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##   [85] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##   [97] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [109] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [121] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [133] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [145] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [157] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [169] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [181] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [193] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [205] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [217] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [229] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [241] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [253] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [265] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [277] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [289] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [301] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [313] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [325] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [337] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [349] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [361] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [373] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [385] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [397] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [409] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [421] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [433] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [445] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [457] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [469] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [481] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [493] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [505] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [517] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [529] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [541] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [553] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [565] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [577] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [589] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [601] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [613] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [625] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [637] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [649] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [661] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [673] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [685] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [697] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [709] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [721] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [733] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [745] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [757] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [769] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [781] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [793] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [805] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [817] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [829] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [841] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [853] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [865] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [877] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [889] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [901] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [913] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [925] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [937] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [949] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [961] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [973] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [985] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
##  [997] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1009] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1021] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1033] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1045] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1057] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1069] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1081] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1093] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1105] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1117] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1129] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1141] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1153] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1165] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1177] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1189] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1201] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1213] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1225] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1237] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1249] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1261] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1273] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1285] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1297] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1309] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1321] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1333] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1345] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1357] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1369] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1381] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1393] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1405] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1417] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1429] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1441] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1453] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1465] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1477] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1489] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1501] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1513] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1525] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1537] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1549] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1561] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1573] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1585] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1597] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1609] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1621] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1633] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1645] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1657] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1669] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1681] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1693] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1705] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1717] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1729] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1741] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1753] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1765] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1777] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1789] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1801] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1813] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1825] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1837] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1849] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1861] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1873] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1885] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1897] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1909] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1921] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1933] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1945] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1957] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1969] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1981] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [1993] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2005] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2017] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2029] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2041] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2053] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2065] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2077] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2089] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2101] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2113] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2125] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2137] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2149] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2161] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2173] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2185] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2197] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2209] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2221] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2233] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2245] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2257] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2269] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2281] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2293] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2305] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2317] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2329] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2341] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2353] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2365] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2377] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2389] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2401] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2413] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2425] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2437] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2449] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2461] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2473] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2485] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2497] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2509] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2521] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2533] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2545] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2557] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2569] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2581] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2593] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2605] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2617] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2629] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2641] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2653] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2665] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2677] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2689] ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..."
## [2701] ""    ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2713] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2725] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2737] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2749] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2761] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2773] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2785] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2797] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2809] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2821] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2833] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2845] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2857] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2869] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2881] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2893] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2905] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2917] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2929] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2941] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2953] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""    "..." ""   
## [2965] "..." ""    "..." ""    "..." ""    "..." ""    "..." ""

Question 7

Step 1: Preserve only the 2nd and the 4th variables in your obtained tibble.

tibble_list <- html_table(table_html[3])
# Extract the content from the list
cast_tibble <- tibble_list[[1]]
cast_tibble
## # A tibble: 2,974 × 4
##    X1    X2               X3    X4                                              
##    <lgl> <chr>            <chr> <chr>                                           
##  1 NA    ""               ""    ""                                              
##  2 NA    "Angela Bassett" "..." "Athena Grant\n         / ...  \n              …
##  3 NA    ""               ""    ""                                              
##  4 NA    "Peter Krause"   "..." "Bobby Nash\n                  108 episodes, 20…
##  5 NA    ""               ""    ""                                              
##  6 NA    "Oliver Stark"   "..." "Evan 'Buck' Buckley\n         / ...  \n       …
##  7 NA    ""               ""    ""                                              
##  8 NA    "Aisha Hinds"    "..." "Henrietta 'Hen' Wilson\n         / ...  \n    …
##  9 NA    ""               ""    ""                                              
## 10 NA    "Kenneth Choi"   "..." "Howie 'Chimney' Han\n         / ...  \n       …
## # ℹ 2,964 more rows
clean <- subset(cast_tibble, X2!="", c(2,4) )

Question 8

Which of the following option(s) can help you rename the variables of a tibble (or a data frame)?

colnames(cast_tibble) <- c("v1","v2")

names(cast_tibble) <- c("v1","v2")
## Warning: The `value` argument of `names<-()` must have the same length as `x` as of
## tibble 3.0.0.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `value` argument of `names<-()` can't be empty as of tibble 3.0.0.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

Question 9

What if you want all Series Visual Effects staff names? This is one of the tables in the above web page, but it can be time-consuming to determine if it is a 20th table or 25th table by hand counting. In this case, using the CSS selector to scrape that table could be an easier approach.After your scraping, how many staff worked for the Series Visual Effects?

Step 1 – Read the HTML Webpage

read_html("https://www.imdb.com/title/tt7235466/fullcredits?ref_=tt_cl_sm")
## {html_document}
## <html xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
## [1] <head>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8 ...
## [2] <body id="styleguide-v2" class="fixed">\n            <img height="1" widt ...

Step 2 – Select HTML Elements

visual_html <- html_element(imdb_html,"#fullcredits_content > table:nth-child(38)")
visual_html
## {html_node}
## <table class="simpleTable simpleCreditsTable">
## [1] <colgroup>\n<col class="column1">\n<col class="column2">\n<col class="col ...
## [2] <tbody>\n<tr>\n<td class="name">\n<a href="/name/nm3824642/?ref_=ttfc_fc_ ...
visual <- html_table(visual_html)
visual
## # A tibble: 186 × 3
##    X1                     X2    X3                                              
##    <chr>                  <chr> <chr>                                           
##  1 Christian Zeiler       ...   digital compositor / digital compositor: FuseFX…
##  2 Katrina Duclos         ...   visual effects editor / visual effects editor: …
##  3 Bryant Reif            ...   cg supervisor (50 episodes, 2019-2022)          
##  4 Tony Pirzadeh          ...   visual effects producer: FuseFX / visual effect…
##  5 Ezra Christian         ...   managing producer (46 episodes, 2021-2024)      
##  6 Timothy Michael Cairns ...   compositing supervisor (44 episodes, 2019-2022) 
##  7 Luciano DiGeronimo     ...   compositing supervisor: FuseFX / digital effect…
##  8 Zachary Goodson        ...   visual effects supervisor / visual effects arti…
##  9 Esmeralda Ramirez      ...   vfx coordinator: FuseFX / vfx coordinator: Fuse…
## 10 Brigitte Bourque       ...   digital effects supervisor: Fuse FX / composite…
## # ℹ 176 more rows