class: center, middle, inverse, title-slide # Curso de R: ## Analizando las 250 mejores películas ### Sonia Pérez Fernández ### Universidad de Oviedo ### 24 enero 2022 --- class: center, middle background-color: rosybrown # ¿Dónde obtenemos los datos? --- <style type="text/css"> pre { background: #FCF3CF; max-width: 100%; overflow-x: scroll; } .scrollable { max-height: 450px; overflow-y: auto; } .scroll-tiny{ max-height: 200px; overflow-y: auto; } .scroll-small{ max-height: 350px; overflow-y: auto; } .scroll-small2{ max-height: 300px; overflow-y: auto; } .scroll-medium{ max-height: 400px; overflow-y: auto; } .remark-code-line-highlighted { background-color: #FADBD8; } </style> # ¿Dónde obtenemos los datos? Datos procedentes de la base de datos en línea .center[[IMDb (Internet Movie Database)](https://www.imdb.com/)] .center[ Menu `\(\rightarrow\)` Movies `\(\rightarrow\)` [Top 250 Movies](https://www.imdb.com/chart/top/?ref_=nv_mv_250) ] .pull-left[ <img src="Screenshot1_IMDb.png", width="200%"> ] .pull-right[ <img src="Screenshot2_IMDb.png", width="70%"> ] --- class: center, middle background-color: rosybrown # ¿Cómo importar datos procedentes de una web en R? --- # ¿Cómo importar datos procedentes de una web en R? Mediante la librería [.purple[`rvest`]](https://cran.r-project.org/web/packages/rvest/index.html). ```r library(rvest) datos <- read_html("https://www.imdb.com/chart/top/?ref_=nv_mv_250") datos ``` ``` ## {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">\n<script type="text/javascript">var ue_t0=ue_t0||+new Date();</script><script type="text/javascript">\nwindow.ue_ihb ... ## [2] <body id="styleguide-v2" class="fixed">\n <img height="1" width="1" style="display:none;visibility:hidden;" src="//fls-na.amazon.com/1/batch/1/OP/A1EVAM02EL8SFB:141-3609411-5962738:4 ... ``` -- <br> .center[.content-box-purple[¿Cómo inspeccionamos el objeto `datos`?]] --- ```r html_elements(datos, "td") # El elemento HTML Celda de tabla (<td>) define la celda de una tabla que contiene datos ``` ``` ## {xml_nodeset (1250)} ## [1] <td class="posterColumn">\n\n <span name="rk" data-value="1"></span>\n <span name="ir" data-value="9.22124886023435"></span>\n <span name="us" data-value="7.791552E11"></span>\n <s ... ## [2] <td class="titleColumn">\n 1.\n <a href="/title/tt0111161/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=9703a62d-b88a-4e30-ae12-90fcafafa3fc&pf_rd_r=4ZTH7S7VA072DSFPVEYT&pf_rd_s=center ... ## [3] <td class="ratingColumn imdbRating">\n <strong title="9.2 based on 2,531,700 user ratings">9.2</strong>\n </td> ## [4] <td class="ratingColumn">\n <div class="seen-widget seen-widget-tt0111161 pending" data-titleid="tt0111161">\n <div class="boundary">\n <div class="popover">\n<span class= ... ## [5] <td class="watchlistColumn">\n <div class="wlb_ribbon" data-tconst="tt0111161" data-recordmetrics="true"></div>\n </td> ## [6] <td class="posterColumn">\n\n <span name="rk" data-value="2"></span>\n <span name="ir" data-value="9.146903497720446"></span>\n <span name="us" data-value="6.93792E10"></span>\n <s ... ## [7] <td class="titleColumn">\n 2.\n <a href="/title/tt0068646/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=9703a62d-b88a-4e30-ae12-90fcafafa3fc&pf_rd_r=4ZTH7S7VA072DSFPVEYT&pf_rd_s=center ... ## [8] <td class="ratingColumn imdbRating">\n <strong title="9.1 based on 1,742,891 user ratings">9.1</strong>\n </td> ## [9] <td class="ratingColumn">\n <div class="seen-widget seen-widget-tt0068646 pending" data-titleid="tt0068646">\n <div class="boundary">\n <div class="popover">\n<span class= ... ## [10] <td class="watchlistColumn">\n <div class="wlb_ribbon" data-tconst="tt0068646" data-recordmetrics="true"></div>\n </td> ## [11] <td class="posterColumn">\n\n <span name="rk" data-value="3"></span>\n <span name="ir" data-value="8.981012102219244"></span>\n <span name="us" data-value="1.560384E11"></span>\n < ... ## [12] <td class="titleColumn">\n 3.\n <a href="/title/tt0071562/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=9703a62d-b88a-4e30-ae12-90fcafafa3fc&pf_rd_r=4ZTH7S7VA072DSFPVEYT&pf_rd_s=center ... ## [13] <td class="ratingColumn imdbRating">\n <strong title="9.0 based on 1,209,198 user ratings">9.0</strong>\n </td> ## [14] <td class="ratingColumn">\n <div class="seen-widget seen-widget-tt0071562 pending" data-titleid="tt0071562">\n <div class="boundary">\n <div class="popover">\n<span class= ... ## [15] <td class="watchlistColumn">\n <div class="wlb_ribbon" data-tconst="tt0071562" data-recordmetrics="true"></div>\n </td> ## [16] <td class="posterColumn">\n\n <span name="rk" data-value="4"></span>\n <span name="ir" data-value="8.976604856389963"></span>\n <span name="us" data-value="1.2159936E12"></span>\n ... ## [17] <td class="titleColumn">\n 4.\n <a href="/title/tt0468569/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=9703a62d-b88a-4e30-ae12-90fcafafa3fc&pf_rd_r=4ZTH7S7VA072DSFPVEYT&pf_rd_s=center ... ## [18] <td class="ratingColumn imdbRating">\n <strong title="9.0 based on 2,482,152 user ratings">9.0</strong>\n </td> ## [19] <td class="ratingColumn">\n <div class="seen-widget seen-widget-tt0468569 pending" data-titleid="tt0468569">\n <div class="boundary">\n <div class="popover">\n<span class= ... ## [20] <td class="watchlistColumn">\n <div class="wlb_ribbon" data-tconst="tt0468569" data-recordmetrics="true"></div>\n </td> ## ... ``` --- # SelectorGadget Se puede instalar [SelectorGadget](https://chrome.google.com/webstore/detail/selectorgadget/mhjhnkcfbdhnjickkkdbjoemdmbfginb?hl=es) como extensión de Chrome o inspeccionar directamente el código fuente y fijarse en la clase/`class` (hasta un espacio). <img src="Screenshot3_IMDb.png", width="99%"> --- # ¿Cómo inspeccionamos el objeto `datos`? .scrollable[ ```r html_elements(datos, ".imdbRating") ``` ``` ## {xml_nodeset (250)} ## [1] <td class="ratingColumn imdbRating">\n <strong title="9.2 based on 2,531,700 user ratings">9.2</strong>\n </td> ## [2] <td class="ratingColumn imdbRating">\n <strong title="9.1 based on 1,742,891 user ratings">9.1</strong>\n </td> ## [3] <td class="ratingColumn imdbRating">\n <strong title="9.0 based on 1,209,198 user ratings">9.0</strong>\n </td> ## [4] <td class="ratingColumn imdbRating">\n <strong title="9.0 based on 2,482,152 user ratings">9.0</strong>\n </td> ## [5] <td class="ratingColumn imdbRating">\n <strong title="8.9 based on 748,065 user ratings">8.9</strong>\n </td> ## [6] <td class="ratingColumn imdbRating">\n <strong title="8.9 based on 1,293,509 user ratings">8.9</strong>\n </td> ## [7] <td class="ratingColumn imdbRating">\n <strong title="8.9 based on 1,747,018 user ratings">8.9</strong>\n </td> ## [8] <td class="ratingColumn imdbRating">\n <strong title="8.8 based on 1,949,998 user ratings">8.8</strong>\n </td> ## [9] <td class="ratingColumn imdbRating">\n <strong title="8.8 based on 731,614 user ratings">8.8</strong>\n </td> ## [10] <td class="ratingColumn imdbRating">\n <strong title="8.8 based on 1,768,396 user ratings">8.8</strong>\n </td> ## [11] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,991,339 user ratings">8.7</strong>\n </td> ## [12] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,953,976 user ratings">8.7</strong>\n </td> ## [13] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 2,224,763 user ratings">8.7</strong>\n </td> ## [14] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,578,445 user ratings">8.7</strong>\n </td> ## [15] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,229,090 user ratings">8.7</strong>\n </td> ## [16] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,826,876 user ratings">8.7</strong>\n </td> ## [17] <td class="ratingColumn imdbRating">\n <strong title="8.6 based on 1,095,102 user ratings">8.6</strong>\n </td> ## [18] <td class="ratingColumn imdbRating">\n <strong title="8.6 based on 969,761 user ratings">8.6</strong>\n </td> ## [19] <td class="ratingColumn imdbRating">\n <strong title="8.6 based on 334,541 user ratings">8.6</strong>\n </td> ## [20] <td class="ratingColumn imdbRating">\n <strong title="8.6 based on 1,553,428 user ratings">8.6</strong>\n </td> ## ... ``` ] --- # ¿Cómo inspeccionamos el objeto `datos`? .scrollable[ ```r html_text(html_elements(datos, ".imdbRating")) ``` ``` ## [1] "\n 9.2\n " ## [2] "\n 9.1\n " ## [3] "\n 9.0\n " ## [4] "\n 9.0\n " ## [5] "\n 8.9\n " ## [6] "\n 8.9\n " ## [7] "\n 8.9\n " ## [8] "\n 8.8\n " ## [9] "\n 8.8\n " ## [10] "\n 8.8\n " ## [11] "\n 8.7\n " ## [12] "\n 8.7\n " ## [13] "\n 8.7\n " ## [14] "\n 8.7\n " ## [15] "\n 8.7\n " ## [16] "\n 8.7\n " ## [17] "\n 8.6\n " ## [18] "\n 8.6\n " ## [19] "\n 8.6\n " ## [20] "\n 8.6\n " ## [21] "\n 8.6\n " ## [22] "\n 8.6\n " ## [23] "\n 8.6\n " ## [24] "\n 8.6\n " ## [25] "\n 8.6\n " ## [26] "\n 8.6\n " ## [27] "\n 8.5\n " ## [28] "\n 8.5\n " ## [29] "\n 8.5\n " ## [30] "\n 8.5\n " ## [31] "\n 8.5\n " ## [32] "\n 8.5\n " ## [33] "\n 8.5\n " ## [34] "\n 8.5\n " ## [35] "\n 8.5\n " ## [36] "\n 8.5\n " ## [37] "\n 8.5\n " ## [38] "\n 8.5\n " ## [39] "\n 8.5\n " ## [40] "\n 8.5\n " ## [41] "\n 8.5\n " ## [42] "\n 8.5\n " ## [43] "\n 8.5\n " ## [44] "\n 8.5\n " ## [45] "\n 8.5\n " ## [46] "\n 8.5\n " ## [47] "\n 8.5\n " ## [48] "\n 8.5\n " ## [49] "\n 8.4\n " ## [50] "\n 8.4\n " ## [51] "\n 8.4\n " ## [52] "\n 8.4\n " ## [53] "\n 8.4\n " ## [54] "\n 8.4\n " ## [55] "\n 8.4\n " ## [56] "\n 8.4\n " ## [57] "\n 8.4\n " ## [58] "\n 8.4\n " ## [59] "\n 8.4\n " ## [60] "\n 8.4\n " ## [61] "\n 8.4\n " ## [62] "\n 8.4\n " ## [63] "\n 8.4\n " ## [64] "\n 8.4\n " ## [65] "\n 8.4\n " ## [66] "\n 8.4\n " ## [67] "\n 8.4\n " ## [68] "\n 8.3\n " ## [69] "\n 8.3\n " ## [70] "\n 8.3\n " ## [71] "\n 8.3\n " ## [72] "\n 8.3\n " ## [73] "\n 8.3\n " ## [74] "\n 8.3\n " ## [75] "\n 8.3\n " ## [76] "\n 8.3\n " ## [77] "\n 8.3\n " ## [78] "\n 8.3\n " ## [79] "\n 8.3\n " ## [80] "\n 8.3\n " ## [81] "\n 8.3\n " ## [82] "\n 8.3\n " ## [83] "\n 8.3\n " ## [84] "\n 8.3\n " ## [85] "\n 8.3\n " ## [86] "\n 8.3\n " ## [87] "\n 8.3\n " ## [88] "\n 8.3\n " ## [89] "\n 8.3\n " ## [90] "\n 8.3\n " ## [91] "\n 8.3\n " ## [92] "\n 8.3\n " ## [93] "\n 8.3\n " ## [94] "\n 8.3\n " ## [95] "\n 8.3\n " ## [96] "\n 8.3\n " ## [97] "\n 8.3\n " ## [98] "\n 8.3\n " ## [99] "\n 8.3\n " ## [100] "\n 8.3\n " ## [101] "\n 8.3\n " ## [102] "\n 8.3\n " ## [103] "\n 8.3\n " ## [104] "\n 8.2\n " ## [105] "\n 8.2\n " ## [106] "\n 8.2\n " ## [107] "\n 8.2\n " ## [108] "\n 8.2\n " ## [109] "\n 8.2\n " ## [110] "\n 8.2\n " ## [111] "\n 8.2\n " ## [112] "\n 8.2\n " ## [113] "\n 8.2\n " ## [114] "\n 8.2\n " ## [115] "\n 8.2\n " ## [116] "\n 8.2\n " ## [117] "\n 8.2\n " ## [118] "\n 8.2\n " ## [119] "\n 8.2\n " ## [120] "\n 8.2\n " ## [121] "\n 8.2\n " ## [122] "\n 8.2\n " ## [123] "\n 8.2\n " ## [124] "\n 8.2\n " ## [125] "\n 8.2\n " ## [126] "\n 8.2\n " ## [127] "\n 8.2\n " ## [128] "\n 8.2\n " ## [129] "\n 8.2\n " ## [130] "\n 8.2\n " ## [131] "\n 8.2\n " ## [132] "\n 8.2\n " ## [133] "\n 8.2\n " ## [134] "\n 8.2\n " ## [135] "\n 8.2\n " ## [136] "\n 8.2\n " ## [137] "\n 8.2\n " ## [138] "\n 8.2\n " ## [139] "\n 8.2\n " ## [140] "\n 8.2\n " ## [141] "\n 8.2\n " ## [142] "\n 8.2\n " ## [143] "\n 8.2\n " ## [144] "\n 8.2\n " ## [145] "\n 8.2\n " ## [146] "\n 8.2\n " ## [147] "\n 8.2\n " ## [148] "\n 8.1\n " ## [149] "\n 8.1\n " ## [150] "\n 8.1\n " ## [151] "\n 8.1\n " ## [152] "\n 8.1\n " ## [153] "\n 8.1\n " ## [154] "\n 8.1\n " ## [155] "\n 8.1\n " ## [156] "\n 8.1\n " ## [157] "\n 8.1\n " ## [158] "\n 8.1\n " ## [159] "\n 8.1\n " ## [160] "\n 8.1\n " ## [161] "\n 8.1\n " ## [162] "\n 8.1\n " ## [163] "\n 8.1\n " ## [164] "\n 8.1\n " ## [165] "\n 8.1\n " ## [166] "\n 8.1\n " ## [167] "\n 8.1\n " ## [168] "\n 8.1\n " ## [169] "\n 8.1\n " ## [170] "\n 8.1\n " ## [171] "\n 8.1\n " ## [172] "\n 8.1\n " ## [173] "\n 8.1\n " ## [174] "\n 8.1\n " ## [175] "\n 8.1\n " ## [176] "\n 8.1\n " ## [177] "\n 8.1\n " ## [178] "\n 8.1\n " ## [179] "\n 8.1\n " ## [180] "\n 8.1\n " ## [181] "\n 8.1\n " ## [182] "\n 8.1\n " ## [183] "\n 8.1\n " ## [184] "\n 8.1\n " ## [185] "\n 8.1\n " ## [186] "\n 8.1\n " ## [187] "\n 8.1\n " ## [188] "\n 8.1\n " ## [189] "\n 8.1\n " ## [190] "\n 8.1\n " ## [191] "\n 8.1\n " ## [192] "\n 8.1\n " ## [193] "\n 8.1\n " ## [194] "\n 8.1\n " ## [195] "\n 8.1\n " ## [196] "\n 8.1\n " ## [197] "\n 8.1\n " ## [198] "\n 8.1\n " ## [199] "\n 8.1\n " ## [200] "\n 8.1\n " ## [201] "\n 8.1\n " ## [202] "\n 8.1\n " ## [203] "\n 8.1\n " ## [204] "\n 8.1\n " ## [205] "\n 8.1\n " ## [206] "\n 8.1\n " ## [207] "\n 8.1\n " ## [208] "\n 8.1\n " ## [209] "\n 8.1\n " ## [210] "\n 8.1\n " ## [211] "\n 8.1\n " ## [212] "\n 8.1\n " ## [213] "\n 8.1\n " ## [214] "\n 8.1\n " ## [215] "\n 8.1\n " ## [216] "\n 8.1\n " ## [217] "\n 8.1\n " ## [218] "\n 8.1\n " ## [219] "\n 8.1\n " ## [220] "\n 8.1\n " ## [221] "\n 8.1\n " ## [222] "\n 8.1\n " ## [223] "\n 8.0\n " ## [224] "\n 8.0\n " ## [225] "\n 8.0\n " ## [226] "\n 8.0\n " ## [227] "\n 8.0\n " ## [228] "\n 8.0\n " ## [229] "\n 8.0\n " ## [230] "\n 8.0\n " ## [231] "\n 8.0\n " ## [232] "\n 8.0\n " ## [233] "\n 8.0\n " ## [234] "\n 8.0\n " ## [235] "\n 8.0\n " ## [236] "\n 8.0\n " ## [237] "\n 8.0\n " ## [238] "\n 8.0\n " ## [239] "\n 8.0\n " ## [240] "\n 8.0\n " ## [241] "\n 8.0\n " ## [242] "\n 8.0\n " ## [243] "\n 8.0\n " ## [244] "\n 8.0\n " ## [245] "\n 8.0\n " ## [246] "\n 8.0\n " ## [247] "\n 8.0\n " ## [248] "\n 8.0\n " ## [249] "\n 8.0\n " ## [250] "\n 8.0\n " ``` ] --- # ¿Cómo inspeccionamos el objeto `datos`? .scrollable[ ```r trimws(html_text(html_elements(datos, ".imdbRating"))) ``` ``` ## [1] "9.2" "9.1" "9.0" "9.0" "8.9" "8.9" "8.9" "8.8" "8.8" "8.8" ## [11] "8.7" "8.7" "8.7" "8.7" "8.7" "8.7" "8.6" "8.6" "8.6" "8.6" ## [21] "8.6" "8.6" "8.6" "8.6" "8.6" "8.6" "8.5" "8.5" "8.5" "8.5" ## [31] "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" ## [41] "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.4" "8.4" ## [51] "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" ## [61] "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.3" "8.3" "8.3" ## [71] "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" ## [81] "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" ## [91] "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" ## [101] "8.3" "8.3" "8.3" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" ## [111] "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" ## [121] "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" ## [131] "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" ## [141] "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.1" "8.1" "8.1" ## [151] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [161] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [171] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [181] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [191] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [201] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [211] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [221] "8.1" "8.1" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" ## [231] "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" ## [241] "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" ``` ] --- # ¿Cómo inspeccionamos el objeto `datos`? .scrollable[ ```r as.numeric(trimws(html_text(html_elements(datos, ".imdbRating")))) ``` ``` ## [1] 9.2 9.1 9.0 9.0 8.9 8.9 8.9 8.8 8.8 8.8 8.7 8.7 8.7 8.7 8.7 ## [16] 8.7 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.5 8.5 8.5 8.5 ## [31] 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 ## [46] 8.5 8.5 8.5 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 ## [61] 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 ## [76] 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 ## [91] 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.2 8.2 ## [106] 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 ## [121] 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 ## [136] 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.1 8.1 8.1 ## [151] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [166] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [181] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [196] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [211] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.0 8.0 8.0 ## [226] 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 ## [241] 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 ``` ] --- class: center, middle background-color: rosybrown # ¿Hay una forma más "elegante" de escribir en R la expresión anterior? ##### `as.numeric(trimws(html_text(html_elements(datos, ".imdbRating"))))` --- # ¿Hay una forma más "elegante" de escribir en R la expresión anterior? Mediante el uso del paquete [.purple[`dplyr`]](https://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf) y, en particular, de las _pipes_ (`%>%`). ```r library(dplyr) ``` -- <br> <img src="Screenshot4_IMDb.png", width="99%"> --- # ¿Cómo funciona `%>%`? .scrollable[ ```r html_elements(datos, ".imdbRating") ``` ``` ## {xml_nodeset (250)} ## [1] <td class="ratingColumn imdbRating">\n <strong title="9.2 based on 2,531,700 user ratings">9.2</strong>\n </td> ## [2] <td class="ratingColumn imdbRating">\n <strong title="9.1 based on 1,742,891 user ratings">9.1</strong>\n </td> ## [3] <td class="ratingColumn imdbRating">\n <strong title="9.0 based on 1,209,198 user ratings">9.0</strong>\n </td> ## [4] <td class="ratingColumn imdbRating">\n <strong title="9.0 based on 2,482,152 user ratings">9.0</strong>\n </td> ## [5] <td class="ratingColumn imdbRating">\n <strong title="8.9 based on 748,065 user ratings">8.9</strong>\n </td> ## [6] <td class="ratingColumn imdbRating">\n <strong title="8.9 based on 1,293,509 user ratings">8.9</strong>\n </td> ## [7] <td class="ratingColumn imdbRating">\n <strong title="8.9 based on 1,747,018 user ratings">8.9</strong>\n </td> ## [8] <td class="ratingColumn imdbRating">\n <strong title="8.8 based on 1,949,998 user ratings">8.8</strong>\n </td> ## [9] <td class="ratingColumn imdbRating">\n <strong title="8.8 based on 731,614 user ratings">8.8</strong>\n </td> ## [10] <td class="ratingColumn imdbRating">\n <strong title="8.8 based on 1,768,396 user ratings">8.8</strong>\n </td> ## [11] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,991,339 user ratings">8.7</strong>\n </td> ## [12] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,953,976 user ratings">8.7</strong>\n </td> ## [13] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 2,224,763 user ratings">8.7</strong>\n </td> ## [14] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,578,445 user ratings">8.7</strong>\n </td> ## [15] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,229,090 user ratings">8.7</strong>\n </td> ## [16] <td class="ratingColumn imdbRating">\n <strong title="8.7 based on 1,826,876 user ratings">8.7</strong>\n </td> ## [17] <td class="ratingColumn imdbRating">\n <strong title="8.6 based on 1,095,102 user ratings">8.6</strong>\n </td> ## [18] <td class="ratingColumn imdbRating">\n <strong title="8.6 based on 969,761 user ratings">8.6</strong>\n </td> ## [19] <td class="ratingColumn imdbRating">\n <strong title="8.6 based on 334,541 user ratings">8.6</strong>\n </td> ## [20] <td class="ratingColumn imdbRating">\n <strong title="8.6 based on 1,553,428 user ratings">8.6</strong>\n </td> ## ... ``` ] --- # ¿Cómo funciona `%>%`? .scrollable[ ```r html_elements(datos, ".imdbRating") %>% * html_text() ``` ``` ## [1] "\n 9.2\n " ## [2] "\n 9.1\n " ## [3] "\n 9.0\n " ## [4] "\n 9.0\n " ## [5] "\n 8.9\n " ## [6] "\n 8.9\n " ## [7] "\n 8.9\n " ## [8] "\n 8.8\n " ## [9] "\n 8.8\n " ## [10] "\n 8.8\n " ## [11] "\n 8.7\n " ## [12] "\n 8.7\n " ## [13] "\n 8.7\n " ## [14] "\n 8.7\n " ## [15] "\n 8.7\n " ## [16] "\n 8.7\n " ## [17] "\n 8.6\n " ## [18] "\n 8.6\n " ## [19] "\n 8.6\n " ## [20] "\n 8.6\n " ## [21] "\n 8.6\n " ## [22] "\n 8.6\n " ## [23] "\n 8.6\n " ## [24] "\n 8.6\n " ## [25] "\n 8.6\n " ## [26] "\n 8.6\n " ## [27] "\n 8.5\n " ## [28] "\n 8.5\n " ## [29] "\n 8.5\n " ## [30] "\n 8.5\n " ## [31] "\n 8.5\n " ## [32] "\n 8.5\n " ## [33] "\n 8.5\n " ## [34] "\n 8.5\n " ## [35] "\n 8.5\n " ## [36] "\n 8.5\n " ## [37] "\n 8.5\n " ## [38] "\n 8.5\n " ## [39] "\n 8.5\n " ## [40] "\n 8.5\n " ## [41] "\n 8.5\n " ## [42] "\n 8.5\n " ## [43] "\n 8.5\n " ## [44] "\n 8.5\n " ## [45] "\n 8.5\n " ## [46] "\n 8.5\n " ## [47] "\n 8.5\n " ## [48] "\n 8.5\n " ## [49] "\n 8.4\n " ## [50] "\n 8.4\n " ## [51] "\n 8.4\n " ## [52] "\n 8.4\n " ## [53] "\n 8.4\n " ## [54] "\n 8.4\n " ## [55] "\n 8.4\n " ## [56] "\n 8.4\n " ## [57] "\n 8.4\n " ## [58] "\n 8.4\n " ## [59] "\n 8.4\n " ## [60] "\n 8.4\n " ## [61] "\n 8.4\n " ## [62] "\n 8.4\n " ## [63] "\n 8.4\n " ## [64] "\n 8.4\n " ## [65] "\n 8.4\n " ## [66] "\n 8.4\n " ## [67] "\n 8.4\n " ## [68] "\n 8.3\n " ## [69] "\n 8.3\n " ## [70] "\n 8.3\n " ## [71] "\n 8.3\n " ## [72] "\n 8.3\n " ## [73] "\n 8.3\n " ## [74] "\n 8.3\n " ## [75] "\n 8.3\n " ## [76] "\n 8.3\n " ## [77] "\n 8.3\n " ## [78] "\n 8.3\n " ## [79] "\n 8.3\n " ## [80] "\n 8.3\n " ## [81] "\n 8.3\n " ## [82] "\n 8.3\n " ## [83] "\n 8.3\n " ## [84] "\n 8.3\n " ## [85] "\n 8.3\n " ## [86] "\n 8.3\n " ## [87] "\n 8.3\n " ## [88] "\n 8.3\n " ## [89] "\n 8.3\n " ## [90] "\n 8.3\n " ## [91] "\n 8.3\n " ## [92] "\n 8.3\n " ## [93] "\n 8.3\n " ## [94] "\n 8.3\n " ## [95] "\n 8.3\n " ## [96] "\n 8.3\n " ## [97] "\n 8.3\n " ## [98] "\n 8.3\n " ## [99] "\n 8.3\n " ## [100] "\n 8.3\n " ## [101] "\n 8.3\n " ## [102] "\n 8.3\n " ## [103] "\n 8.3\n " ## [104] "\n 8.2\n " ## [105] "\n 8.2\n " ## [106] "\n 8.2\n " ## [107] "\n 8.2\n " ## [108] "\n 8.2\n " ## [109] "\n 8.2\n " ## [110] "\n 8.2\n " ## [111] "\n 8.2\n " ## [112] "\n 8.2\n " ## [113] "\n 8.2\n " ## [114] "\n 8.2\n " ## [115] "\n 8.2\n " ## [116] "\n 8.2\n " ## [117] "\n 8.2\n " ## [118] "\n 8.2\n " ## [119] "\n 8.2\n " ## [120] "\n 8.2\n " ## [121] "\n 8.2\n " ## [122] "\n 8.2\n " ## [123] "\n 8.2\n " ## [124] "\n 8.2\n " ## [125] "\n 8.2\n " ## [126] "\n 8.2\n " ## [127] "\n 8.2\n " ## [128] "\n 8.2\n " ## [129] "\n 8.2\n " ## [130] "\n 8.2\n " ## [131] "\n 8.2\n " ## [132] "\n 8.2\n " ## [133] "\n 8.2\n " ## [134] "\n 8.2\n " ## [135] "\n 8.2\n " ## [136] "\n 8.2\n " ## [137] "\n 8.2\n " ## [138] "\n 8.2\n " ## [139] "\n 8.2\n " ## [140] "\n 8.2\n " ## [141] "\n 8.2\n " ## [142] "\n 8.2\n " ## [143] "\n 8.2\n " ## [144] "\n 8.2\n " ## [145] "\n 8.2\n " ## [146] "\n 8.2\n " ## [147] "\n 8.2\n " ## [148] "\n 8.1\n " ## [149] "\n 8.1\n " ## [150] "\n 8.1\n " ## [151] "\n 8.1\n " ## [152] "\n 8.1\n " ## [153] "\n 8.1\n " ## [154] "\n 8.1\n " ## [155] "\n 8.1\n " ## [156] "\n 8.1\n " ## [157] "\n 8.1\n " ## [158] "\n 8.1\n " ## [159] "\n 8.1\n " ## [160] "\n 8.1\n " ## [161] "\n 8.1\n " ## [162] "\n 8.1\n " ## [163] "\n 8.1\n " ## [164] "\n 8.1\n " ## [165] "\n 8.1\n " ## [166] "\n 8.1\n " ## [167] "\n 8.1\n " ## [168] "\n 8.1\n " ## [169] "\n 8.1\n " ## [170] "\n 8.1\n " ## [171] "\n 8.1\n " ## [172] "\n 8.1\n " ## [173] "\n 8.1\n " ## [174] "\n 8.1\n " ## [175] "\n 8.1\n " ## [176] "\n 8.1\n " ## [177] "\n 8.1\n " ## [178] "\n 8.1\n " ## [179] "\n 8.1\n " ## [180] "\n 8.1\n " ## [181] "\n 8.1\n " ## [182] "\n 8.1\n " ## [183] "\n 8.1\n " ## [184] "\n 8.1\n " ## [185] "\n 8.1\n " ## [186] "\n 8.1\n " ## [187] "\n 8.1\n " ## [188] "\n 8.1\n " ## [189] "\n 8.1\n " ## [190] "\n 8.1\n " ## [191] "\n 8.1\n " ## [192] "\n 8.1\n " ## [193] "\n 8.1\n " ## [194] "\n 8.1\n " ## [195] "\n 8.1\n " ## [196] "\n 8.1\n " ## [197] "\n 8.1\n " ## [198] "\n 8.1\n " ## [199] "\n 8.1\n " ## [200] "\n 8.1\n " ## [201] "\n 8.1\n " ## [202] "\n 8.1\n " ## [203] "\n 8.1\n " ## [204] "\n 8.1\n " ## [205] "\n 8.1\n " ## [206] "\n 8.1\n " ## [207] "\n 8.1\n " ## [208] "\n 8.1\n " ## [209] "\n 8.1\n " ## [210] "\n 8.1\n " ## [211] "\n 8.1\n " ## [212] "\n 8.1\n " ## [213] "\n 8.1\n " ## [214] "\n 8.1\n " ## [215] "\n 8.1\n " ## [216] "\n 8.1\n " ## [217] "\n 8.1\n " ## [218] "\n 8.1\n " ## [219] "\n 8.1\n " ## [220] "\n 8.1\n " ## [221] "\n 8.1\n " ## [222] "\n 8.1\n " ## [223] "\n 8.0\n " ## [224] "\n 8.0\n " ## [225] "\n 8.0\n " ## [226] "\n 8.0\n " ## [227] "\n 8.0\n " ## [228] "\n 8.0\n " ## [229] "\n 8.0\n " ## [230] "\n 8.0\n " ## [231] "\n 8.0\n " ## [232] "\n 8.0\n " ## [233] "\n 8.0\n " ## [234] "\n 8.0\n " ## [235] "\n 8.0\n " ## [236] "\n 8.0\n " ## [237] "\n 8.0\n " ## [238] "\n 8.0\n " ## [239] "\n 8.0\n " ## [240] "\n 8.0\n " ## [241] "\n 8.0\n " ## [242] "\n 8.0\n " ## [243] "\n 8.0\n " ## [244] "\n 8.0\n " ## [245] "\n 8.0\n " ## [246] "\n 8.0\n " ## [247] "\n 8.0\n " ## [248] "\n 8.0\n " ## [249] "\n 8.0\n " ## [250] "\n 8.0\n " ``` ] --- # ¿Cómo funciona `%>%`? .scrollable[ ```r html_elements(datos, ".imdbRating") %>% html_text() %>% * trimws() ``` ``` ## [1] "9.2" "9.1" "9.0" "9.0" "8.9" "8.9" "8.9" "8.8" "8.8" "8.8" ## [11] "8.7" "8.7" "8.7" "8.7" "8.7" "8.7" "8.6" "8.6" "8.6" "8.6" ## [21] "8.6" "8.6" "8.6" "8.6" "8.6" "8.6" "8.5" "8.5" "8.5" "8.5" ## [31] "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" ## [41] "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.5" "8.4" "8.4" ## [51] "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" ## [61] "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.4" "8.3" "8.3" "8.3" ## [71] "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" ## [81] "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" ## [91] "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" "8.3" ## [101] "8.3" "8.3" "8.3" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" ## [111] "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" ## [121] "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" ## [131] "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" ## [141] "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.2" "8.1" "8.1" "8.1" ## [151] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [161] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [171] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [181] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [191] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [201] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [211] "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" "8.1" ## [221] "8.1" "8.1" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" ## [231] "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" ## [241] "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" "8.0" ``` ] --- # ¿Cómo funciona `%>%`? .scrollable[ ```r html_elements(datos, ".imdbRating") %>% html_text() %>% trimws() %>% * as.numeric() ``` ``` ## [1] 9.2 9.1 9.0 9.0 8.9 8.9 8.9 8.8 8.8 8.8 8.7 8.7 8.7 8.7 8.7 ## [16] 8.7 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.5 8.5 8.5 8.5 ## [31] 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 ## [46] 8.5 8.5 8.5 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 ## [61] 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 ## [76] 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 ## [91] 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.2 8.2 ## [106] 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 ## [121] 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 ## [136] 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.1 8.1 8.1 ## [151] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [166] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [181] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [196] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [211] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.0 8.0 8.0 ## [226] 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 ## [241] 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 ``` ] --- class: center, middle background-color: rosybrown # ¿Cómo obtenemos otros campos disponibles en la página web? ## Tíulo de la película, año de lanzamiento, puntuación, popularidad... --- # ¿Cómo obtenemos el título de la película? .scrollable[ ```r html_elements(datos, ".titleColumn") %>% html_text() ``` ``` ## [1] "\n 1.\n Cadena perpetua\n (1994)\n " ## [2] "\n 2.\n El padrino\n (1972)\n " ## [3] "\n 3.\n El padrino: Parte II\n (1974)\n " ## [4] "\n 4.\n El caballero oscuro\n (2008)\n " ## [5] "\n 5.\n 12 hombres sin piedad\n (1957)\n " ## [6] "\n 6.\n La lista de Schindler\n (1993)\n " ## [7] "\n 7.\n El señor de los anillos: El retorno del rey\n (2003)\n " ## [8] "\n 8.\n Pulp Fiction\n (1994)\n " ## [9] "\n 9.\n El bueno, el feo y el malo\n (1966)\n " ## [10] "\n 10.\n El señor de los anillos: La comunidad del anillo\n (2001)\n " ## [11] "\n 11.\n El club de la lucha\n (1999)\n " ## [12] "\n 12.\n Forrest Gump\n (1994)\n " ## [13] "\n 13.\n Origen\n (2010)\n " ## [14] "\n 14.\n El señor de los anillos: Las dos torres\n (2002)\n " ## [15] "\n 15.\n El Imperio contraataca\n (1980)\n " ## [16] "\n 16.\n Matrix\n (1999)\n " ## [17] "\n 17.\n Uno de los nuestros\n (1990)\n " ## [18] "\n 18.\n Alguien voló sobre el nido del cuco\n (1975)\n " ## [19] "\n 19.\n Los siete samuráis\n (1954)\n " ## [20] "\n 20.\n Seven\n (1995)\n " ## [21] "\n 21.\n Spider-Man: No Way Home\n (2021)\n " ## [22] "\n 22.\n El silencio de los corderos\n (1991)\n " ## [23] "\n 23.\n Ciudad de Dios\n (2002)\n " ## [24] "\n 24.\n ¡Qué bello es vivir!\n (1946)\n " ## [25] "\n 25.\n La vida es bella\n (1997)\n " ## [26] "\n 26.\n Salvar al soldado Ryan\n (1998)\n " ## [27] "\n 27.\n La guerra de las galaxias\n (1977)\n " ## [28] "\n 28.\n Interstellar\n (2014)\n " ## [29] "\n 29.\n El viaje de Chihiro\n (2001)\n " ## [30] "\n 30.\n La milla verde\n (1999)\n " ## [31] "\n 31.\n Parásitos\n (2019)\n " ## [32] "\n 32.\n El profesional (Léon)\n (1994)\n " ## [33] "\n 33.\n Harakiri\n (1962)\n " ## [34] "\n 34.\n El pianista\n (2002)\n " ## [35] "\n 35.\n Terminator 2: El juicio final\n (1991)\n " ## [36] "\n 36.\n Regreso al futuro\n (1985)\n " ## [37] "\n 37.\n Sospechosos habituales\n (1995)\n " ## [38] "\n 38.\n Psicosis\n (1960)\n " ## [39] "\n 39.\n El rey león\n (1994)\n " ## [40] "\n 40.\n Tiempos modernos\n (1936)\n " ## [41] "\n 41.\n La tumba de las luciérnagas\n (1988)\n " ## [42] "\n 42.\n American History X\n (1998)\n " ## [43] "\n 43.\n Whiplash\n (2014)\n " ## [44] "\n 44.\n Gladiator (El gladiador)\n (2000)\n " ## [45] "\n 45.\n Luces de la ciudad\n (1931)\n " ## [46] "\n 46.\n Infiltrados\n (2006)\n " ## [47] "\n 47.\n Intocable\n (2011)\n " ## [48] "\n 48.\n El truco final (El prestigio)\n (2006)\n " ## [49] "\n 49.\n Casablanca\n (1942)\n " ## [50] "\n 50.\n Hasta que llegó su hora\n (1968)\n " ## [51] "\n 51.\n La ventana indiscreta\n (1954)\n " ## [52] "\n 52.\n Cinema Paradiso\n (1988)\n " ## [53] "\n 53.\n Alien, el octavo pasajero\n (1979)\n " ## [54] "\n 54.\n Apocalypse Now\n (1979)\n " ## [55] "\n 55.\n Memento\n (2000)\n " ## [56] "\n 56.\n En busca del arca perdida\n (1981)\n " ## [57] "\n 57.\n El gran dictador\n (1940)\n " ## [58] "\n 58.\n Django desencadenado\n (2012)\n " ## [59] "\n 59.\n La vida de los otros\n (2006)\n " ## [60] "\n 60.\n Senderos de gloria\n (1957)\n " ## [61] "\n 61.\n El crepúsculo de los dioses\n (1950)\n " ## [62] "\n 62.\n WALL·E\n (2008)\n " ## [63] "\n 63.\n Vengadores: Infinity War\n (2018)\n " ## [64] "\n 64.\n Testigo de cargo\n (1957)\n " ## [65] "\n 65.\n Spider-Man: Un nuevo universo\n (2018)\n " ## [66] "\n 66.\n El resplandor\n (1980)\n " ## [67] "\n 67.\n ¿Teléfono rojo? Volamos hacia Moscú\n (1964)\n " ## [68] "\n 68.\n La princesa Mononoke\n (1997)\n " ## [69] "\n 69.\n Old Boy\n (2003)\n " ## [70] "\n 70.\n Joker\n (2019)\n " ## [71] "\n 71.\n Your Name.\n (2016)\n " ## [72] "\n 72.\n Coco\n (2017)\n " ## [73] "\n 73.\n El caballero oscuro: La leyenda renace\n (2012)\n " ## [74] "\n 74.\n Aliens: El regreso\n (1986)\n " ## [75] "\n 75.\n Érase una vez en América\n (1984)\n " ## [76] "\n 76.\n Vengadores: Endgame\n (2019)\n " ## [77] "\n 77.\n Cafarnaúm\n (2018)\n " ## [78] "\n 78.\n El submarino (Das Boot)\n (1981)\n " ## [79] "\n 79.\n El infierno del odio\n (1963)\n " ## [80] "\n 80.\n 3 Idiots\n (2009)\n " ## [81] "\n 81.\n Toy Story\n (1995)\n " ## [82] "\n 82.\n Amadeus\n (1984)\n " ## [83] "\n 83.\n American Beauty\n (1999)\n " ## [84] "\n 84.\n Braveheart\n (1995)\n " ## [85] "\n 85.\n Malditos bastardos\n (2009)\n " ## [86] "\n 86.\n El indomable Will Hunting\n (1997)\n " ## [87] "\n 87.\n Hamilton\n (2020)\n " ## [88] "\n 88.\n El retorno del jedi\n (1983)\n " ## [89] "\n 89.\n Masacre (Ven y mira)\n (1985)\n " ## [90] "\n 90.\n 2001: Una odisea del espacio\n (1968)\n " ## [91] "\n 91.\n Reservoir Dogs\n (1992)\n " ## [92] "\n 92.\n Taare Zameen Par\n (2007)\n " ## [93] "\n 93.\n Vértigo (De entre los muertos)\n (1958)\n " ## [94] "\n 94.\n M, el vampiro de Düsseldorf\n (1931)\n " ## [95] "\n 95.\n La caza\n (2012)\n " ## [96] "\n 96.\n Ciudadano Kane\n (1941)\n " ## [97] "\n 97.\n Réquiem por un sueño\n (2000)\n " ## [98] "\n 98.\n Cantando bajo la lluvia\n (1952)\n " ## [99] "\n 99.\n Con la muerte en los talones\n (1959)\n " ## [100] "\n 100.\n ¡Olvídate de mí!\n (2004)\n " ## [101] "\n 101.\n Ikiru (Vivir)\n (1952)\n " ## [102] "\n 102.\n Ladrón de bicicletas\n (1948)\n " ## [103] "\n 103.\n Lawrence de Arabia\n (1962)\n " ## [104] "\n 104.\n El chico\n (1921)\n " ## [105] "\n 105.\n La chaqueta metálica\n (1987)\n " ## [106] "\n 106.\n Incendios\n (2010)\n " ## [107] "\n 107.\n Dangal\n (2016)\n " ## [108] "\n 108.\n El apartamento\n (1960)\n " ## [109] "\n 109.\n Perdición\n (1944)\n " ## [110] "\n 110.\n Metrópolis\n (1927)\n " ## [111] "\n 111.\n El padre\n (2020)\n " ## [112] "\n 112.\n Nader y Simin, una separación\n (2011)\n " ## [113] "\n 113.\n Taxi Driver\n (1976)\n " ## [114] "\n 114.\n La naranja mecánica\n (1971)\n " ## [115] "\n 115.\n El golpe\n (1973)\n " ## [116] "\n 116.\n El precio del poder\n (1983)\n " ## [117] "\n 117.\n Snatch, cerdos y diamantes\n (2000)\n " ## [118] "\n 118.\n 1917\n (2019)\n " ## [119] "\n 119.\n Amelie\n (2001)\n " ## [120] "\n 120.\n Matar a un ruiseñor\n (1962)\n " ## [121] "\n 121.\n Toy Story 3\n (2010)\n " ## [122] "\n 122.\n La muerte tenía un precio\n (1965)\n " ## [123] "\n 123.\n Pather Panchali (La canción del camino)\n (1955)\n " ## [124] "\n 124.\n Up\n (2009)\n " ## [125] "\n 125.\n Indiana Jones y la última cruzada\n (1989)\n " ## [126] "\n 126.\n Heat\n (1995)\n " ## [127] "\n 127.\n L.A. Confidential\n (1997)\n " ## [128] "\n 128.\n Ran\n (1985)\n " ## [129] "\n 129.\n Yojimbo\n (1961)\n " ## [130] "\n 130.\n Jungla de cristal\n (1988)\n " ## [131] "\n 131.\n Green Book\n (2018)\n " ## [132] "\n 132.\n Rashomon\n (1950)\n " ## [133] "\n 133.\n El hundimiento\n (2004)\n " ## [134] "\n 134.\n Eva al desnudo\n (1950)\n " ## [135] "\n 135.\n Los caballeros de la mesa cuadrada y sus locos seguidores\n (1975)\n " ## [136] "\n 136.\n Con faldas y a lo loco\n (1959)\n " ## [137] "\n 137.\n Batman Begins\n (2005)\n " ## [138] "\n 138.\n Sin perdón\n (1992)\n " ## [139] "\n 139.\n Children of Heaven\n (1997)\n " ## [140] "\n 140.\n Jai Bhim\n (2021)\n " ## [141] "\n 141.\n El castillo ambulante\n (2004)\n " ## [142] "\n 142.\n El lobo de Wall Street\n (2013)\n " ## [143] "\n 143.\n Vencedores o vencidos\n (1961)\n " ## [144] "\n 144.\n Pozos de ambición\n (2007)\n " ## [145] "\n 145.\n La gran evasión\n (1963)\n " ## [146] "\n 146.\n Casino\n (1995)\n " ## [147] "\n 147.\n El tesoro de Sierra Madre\n (1948)\n " ## [148] "\n 148.\n El laberinto del fauno\n (2006)\n " ## [149] "\n 149.\n Una mente maravillosa\n (2001)\n " ## [150] "\n 150.\n El secreto de sus ojos\n (2009)\n " ## [151] "\n 151.\n Toro salvaje\n (1980)\n " ## [152] "\n 152.\n Chinatown\n (1974)\n " ## [153] "\n 153.\n Mi vecino Totoro\n (1988)\n " ## [154] "\n 154.\n Shutter Island\n (2010)\n " ## [155] "\n 155.\n Lock & Stock\n (1998)\n " ## [156] "\n 156.\n No es país para viejos\n (2007)\n " ## [157] "\n 157.\n Klaus\n (2019)\n " ## [158] "\n 158.\n Crimen perfecto\n (1954)\n " ## [159] "\n 159.\n La quimera del oro\n (1925)\n " ## [160] "\n 160.\n La cosa\n (1982)\n " ## [161] "\n 161.\n Tres anuncios en las afueras\n (2017)\n " ## [162] "\n 162.\n Dersu Uzala (El cazador)\n (1975)\n " ## [163] "\n 163.\n El séptimo sello\n (1957)\n " ## [164] "\n 164.\n El hombre elefante\n (1980)\n " ## [165] "\n 165.\n El sexto sentido\n (1999)\n " ## [166] "\n 166.\n El show de Truman\n (1998)\n " ## [167] "\n 167.\n Jurassic Park (Parque Jurásico)\n (1993)\n " ## [168] "\n 168.\n Fresas salvajes\n (1957)\n " ## [169] "\n 169.\n El tercer hombre\n (1949)\n " ## [170] "\n 170.\n Memories of Murder (Crónica de un asesino en serie)\n (2003)\n " ## [171] "\n 171.\n V de Vendetta\n (2005)\n " ## [172] "\n 172.\n Blade Runner\n (1982)\n " ## [173] "\n 173.\n Trainspotting\n (1996)\n " ## [174] "\n 174.\n Fargo\n (1996)\n " ## [175] "\n 175.\n El puente sobre el río Kwai\n (1957)\n " ## [176] "\n 176.\n Del revés (Inside Out)\n (2015)\n " ## [177] "\n 177.\n Buscando a Nemo\n (2003)\n " ## [178] "\n 178.\n Kill Bill: Volumen 1\n (2003)\n " ## [179] "\n 179.\n Warrior\n (2011)\n " ## [180] "\n 180.\n Lo que el viento se llevó\n (1939)\n " ## [181] "\n 181.\n Cuentos de Tokio\n (1953)\n " ## [182] "\n 182.\n La ley del silencio\n (1954)\n " ## [183] "\n 183.\n Mi padre y mi hijo\n (2005)\n " ## [184] "\n 184.\n Relatos salvajes\n (2014)\n " ## [185] "\n 185.\n Prisioneros\n (2013)\n " ## [186] "\n 186.\n Stalker\n (1979)\n " ## [187] "\n 187.\n El gran hotel Budapest\n (2014)\n " ## [188] "\n 188.\n El cazador\n (1978)\n " ## [189] "\n 189.\n El moderno Sherlock Holmes\n (1924)\n " ## [190] "\n 190.\n El maquinista de La General\n (1926)\n " ## [191] "\n 191.\n Gran Torino\n (2008)\n " ## [192] "\n 192.\n Persona\n (1966)\n " ## [193] "\n 193.\n Antes de amanecer\n (1995)\n " ## [194] "\n 194.\n Mary and Max\n (2009)\n " ## [195] "\n 195.\n Atrápame si puedes\n (2002)\n " ## [196] "\n 196.\n Dune\n (2021)\n " ## [197] "\n 197.\n Caballero sin espada\n (1939)\n " ## [198] "\n 198.\n Barry Lyndon\n (1975)\n " ## [199] "\n 199.\n Z\n (1969)\n " ## [200] "\n 200.\n En el nombre del padre\n (1993)\n " ## [201] "\n 201.\n Hasta el último hombre\n (2016)\n " ## [202] "\n 202.\n Perdida\n (2014)\n " ## [203] "\n 203.\n La habitación\n (2015)\n " ## [204] "\n 204.\n La pasión de Juana de Arco\n (1928)\n " ## [205] "\n 205.\n Andhadhun\n (2018)\n " ## [206] "\n 206.\n Le Mans '66\n (2019)\n " ## [207] "\n 207.\n 12 años de esclavitud\n (2013)\n " ## [208] "\n 208.\n Ser o no ser\n (1942)\n " ## [209] "\n 209.\n El gran Lebowski\n (1998)\n " ## [210] "\n 210.\n El club de los poetas muertos\n (1989)\n " ## [211] "\n 211.\n Harry Potter y las Reliquias de la Muerte - Parte 2\n (2011)\n " ## [212] "\n 212.\n Ben-Hur\n (1959)\n " ## [213] "\n 213.\n Cómo entrenar a tu dragón\n (2010)\n " ## [214] "\n 214.\n Mad Max: Furia en la carretera\n (2015)\n " ## [215] "\n 215.\n Sonata de otoño\n (1978)\n " ## [216] "\n 216.\n Million Dollar Baby\n (2004)\n " ## [217] "\n 217.\n El salario del miedo\n (1953)\n " ## [218] "\n 218.\n Cuenta conmigo\n (1986)\n " ## [219] "\n 219.\n La doncella\n (2016)\n " ## [220] "\n 220.\n Network, un mundo implacable\n (1976)\n " ## [221] "\n 221.\n Logan\n (2017)\n " ## [222] "\n 222.\n El odio\n (1995)\n " ## [223] "\n 223.\n A Silent Voice\n (2016)\n " ## [224] "\n 224.\n La leyenda del indomable\n (1967)\n " ## [225] "\n 225.\n Siempre a tu lado (Hachiko)\n (2009)\n " ## [226] "\n 226.\n Gangs of Wasseypur\n (2012)\n " ## [227] "\n 227.\n Los cuatrocientos golpes\n (1959)\n " ## [228] "\n 228.\n Platoon\n (1986)\n " ## [229] "\n 229.\n Spotlight\n (2015)\n " ## [230] "\n 230.\n Monstruos, S.A.\n (2001)\n " ## [231] "\n 231.\n Rebeca\n (1940)\n " ## [232] "\n 232.\n La vida de Brian\n (1979)\n " ## [233] "\n 233.\n Deseando amar\n (2000)\n " ## [234] "\n 234.\n Hotel Rwanda\n (2004)\n " ## [235] "\n 235.\n Eskiya\n (1996)\n " ## [236] "\n 236.\n Rush\n (2013)\n " ## [237] "\n 237.\n Rocky\n (1976)\n " ## [238] "\n 238.\n Amores perros\n (2000)\n " ## [239] "\n 239.\n Hacia rutas salvajes\n (2007)\n " ## [240] "\n 240.\n Nausicaä del Valle del Viento\n (1984)\n " ## [241] "\n 241.\n Sucedió una noche\n (1934)\n " ## [242] "\n 242.\n Antes del atardecer\n (2004)\n " ## [243] "\n 243.\n Fanny y Alexander\n (1982)\n " ## [244] "\n 244.\n Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito\n (2020)\n " ## [245] "\n 245.\n La batalla de Argel\n (1966)\n " ## [246] "\n 246.\n Las noches de Cabiria\n (1957)\n " ## [247] "\n 247.\n Drishyam\n (2013)\n " ## [248] "\n 248.\n Andrei Rublev\n (1966)\n " ## [249] "\n 249.\n Neon Genesis Evangelion: The End of Evangelion\n (1997)\n " ## [250] "\n 250.\n La princesa prometida\n (1987)\n " ``` ] --- # ¿Cómo obtenemos el título de la película? .scrollable[ ```r html_elements(datos, ".titleColumn") %>% html_text() %>% * strsplit("\n") ``` ``` ## [[1]] ## [1] "" " 1." ## [3] " Cadena perpetua" " (1994)" ## [5] " " ## ## [[2]] ## [1] "" " 2." " El padrino" ## [4] " (1972)" " " ## ## [[3]] ## [1] "" " 3." ## [3] " El padrino: Parte II" " (1974)" ## [5] " " ## ## [[4]] ## [1] "" " 4." ## [3] " El caballero oscuro" " (2008)" ## [5] " " ## ## [[5]] ## [1] "" " 5." ## [3] " 12 hombres sin piedad" " (1957)" ## [5] " " ## ## [[6]] ## [1] "" " 6." ## [3] " La lista de Schindler" " (1993)" ## [5] " " ## ## [[7]] ## [1] "" ## [2] " 7." ## [3] " El señor de los anillos: El retorno del rey" ## [4] " (2003)" ## [5] " " ## ## [[8]] ## [1] "" " 8." ## [3] " Pulp Fiction" " (1994)" ## [5] " " ## ## [[9]] ## [1] "" ## [2] " 9." ## [3] " El bueno, el feo y el malo" ## [4] " (1966)" ## [5] " " ## ## [[10]] ## [1] "" ## [2] " 10." ## [3] " El señor de los anillos: La comunidad del anillo" ## [4] " (2001)" ## [5] " " ## ## [[11]] ## [1] "" " 11." ## [3] " El club de la lucha" " (1999)" ## [5] " " ## ## [[12]] ## [1] "" " 12." ## [3] " Forrest Gump" " (1994)" ## [5] " " ## ## [[13]] ## [1] "" " 13." " Origen" ## [4] " (2010)" " " ## ## [[14]] ## [1] "" ## [2] " 14." ## [3] " El señor de los anillos: Las dos torres" ## [4] " (2002)" ## [5] " " ## ## [[15]] ## [1] "" " 15." ## [3] " El Imperio contraataca" " (1980)" ## [5] " " ## ## [[16]] ## [1] "" " 16." " Matrix" ## [4] " (1999)" " " ## ## [[17]] ## [1] "" " 17." ## [3] " Uno de los nuestros" " (1990)" ## [5] " " ## ## [[18]] ## [1] "" ## [2] " 18." ## [3] " Alguien voló sobre el nido del cuco" ## [4] " (1975)" ## [5] " " ## ## [[19]] ## [1] "" " 19." ## [3] " Los siete samuráis" " (1954)" ## [5] " " ## ## [[20]] ## [1] "" " 20." " Seven" ## [4] " (1995)" " " ## ## [[21]] ## [1] "" ## [2] " 21." ## [3] " Spider-Man: No Way Home" ## [4] " (2021)" ## [5] " " ## ## [[22]] ## [1] "" ## [2] " 22." ## [3] " El silencio de los corderos" ## [4] " (1991)" ## [5] " " ## ## [[23]] ## [1] "" " 23." ## [3] " Ciudad de Dios" " (2002)" ## [5] " " ## ## [[24]] ## [1] "" " 24." ## [3] " ¡Qué bello es vivir!" " (1946)" ## [5] " " ## ## [[25]] ## [1] "" " 25." ## [3] " La vida es bella" " (1997)" ## [5] " " ## ## [[26]] ## [1] "" " 26." ## [3] " Salvar al soldado Ryan" " (1998)" ## [5] " " ## ## [[27]] ## [1] "" ## [2] " 27." ## [3] " La guerra de las galaxias" ## [4] " (1977)" ## [5] " " ## ## [[28]] ## [1] "" " 28." ## [3] " Interstellar" " (2014)" ## [5] " " ## ## [[29]] ## [1] "" " 29." ## [3] " El viaje de Chihiro" " (2001)" ## [5] " " ## ## [[30]] ## [1] "" " 30." ## [3] " La milla verde" " (1999)" ## [5] " " ## ## [[31]] ## [1] "" " 31." " Parásitos" ## [4] " (2019)" " " ## ## [[32]] ## [1] "" " 32." ## [3] " El profesional (Léon)" " (1994)" ## [5] " " ## ## [[33]] ## [1] "" " 33." " Harakiri" ## [4] " (1962)" " " ## ## [[34]] ## [1] "" " 34." " El pianista" ## [4] " (2002)" " " ## ## [[35]] ## [1] "" ## [2] " 35." ## [3] " Terminator 2: El juicio final" ## [4] " (1991)" ## [5] " " ## ## [[36]] ## [1] "" " 36." ## [3] " Regreso al futuro" " (1985)" ## [5] " " ## ## [[37]] ## [1] "" " 37." ## [3] " Sospechosos habituales" " (1995)" ## [5] " " ## ## [[38]] ## [1] "" " 38." " Psicosis" ## [4] " (1960)" " " ## ## [[39]] ## [1] "" " 39." " El rey león" ## [4] " (1994)" " " ## ## [[40]] ## [1] "" " 40." ## [3] " Tiempos modernos" " (1936)" ## [5] " " ## ## [[41]] ## [1] "" ## [2] " 41." ## [3] " La tumba de las luciérnagas" ## [4] " (1988)" ## [5] " " ## ## [[42]] ## [1] "" " 42." ## [3] " American History X" " (1998)" ## [5] " " ## ## [[43]] ## [1] "" " 43." " Whiplash" ## [4] " (2014)" " " ## ## [[44]] ## [1] "" ## [2] " 44." ## [3] " Gladiator (El gladiador)" ## [4] " (2000)" ## [5] " " ## ## [[45]] ## [1] "" " 45." ## [3] " Luces de la ciudad" " (1931)" ## [5] " " ## ## [[46]] ## [1] "" " 46." " Infiltrados" ## [4] " (2006)" " " ## ## [[47]] ## [1] "" " 47." " Intocable" ## [4] " (2011)" " " ## ## [[48]] ## [1] "" ## [2] " 48." ## [3] " El truco final (El prestigio)" ## [4] " (2006)" ## [5] " " ## ## [[49]] ## [1] "" " 49." " Casablanca" ## [4] " (1942)" " " ## ## [[50]] ## [1] "" ## [2] " 50." ## [3] " Hasta que llegó su hora" ## [4] " (1968)" ## [5] " " ## ## [[51]] ## [1] "" " 51." ## [3] " La ventana indiscreta" " (1954)" ## [5] " " ## ## [[52]] ## [1] "" " 52." ## [3] " Cinema Paradiso" " (1988)" ## [5] " " ## ## [[53]] ## [1] "" ## [2] " 53." ## [3] " Alien, el octavo pasajero" ## [4] " (1979)" ## [5] " " ## ## [[54]] ## [1] "" " 54." ## [3] " Apocalypse Now" " (1979)" ## [5] " " ## ## [[55]] ## [1] "" " 55." " Memento" ## [4] " (2000)" " " ## ## [[56]] ## [1] "" ## [2] " 56." ## [3] " En busca del arca perdida" ## [4] " (1981)" ## [5] " " ## ## [[57]] ## [1] "" " 57." ## [3] " El gran dictador" " (1940)" ## [5] " " ## ## [[58]] ## [1] "" " 58." ## [3] " Django desencadenado" " (2012)" ## [5] " " ## ## [[59]] ## [1] "" " 59." ## [3] " La vida de los otros" " (2006)" ## [5] " " ## ## [[60]] ## [1] "" " 60." ## [3] " Senderos de gloria" " (1957)" ## [5] " " ## ## [[61]] ## [1] "" ## [2] " 61." ## [3] " El crepúsculo de los dioses" ## [4] " (1950)" ## [5] " " ## ## [[62]] ## [1] "" " 62." " WALL·E" ## [4] " (2008)" " " ## ## [[63]] ## [1] "" ## [2] " 63." ## [3] " Vengadores: Infinity War" ## [4] " (2018)" ## [5] " " ## ## [[64]] ## [1] "" " 64." ## [3] " Testigo de cargo" " (1957)" ## [5] " " ## ## [[65]] ## [1] "" ## [2] " 65." ## [3] " Spider-Man: Un nuevo universo" ## [4] " (2018)" ## [5] " " ## ## [[66]] ## [1] "" " 66." ## [3] " El resplandor" " (1980)" ## [5] " " ## ## [[67]] ## [1] "" ## [2] " 67." ## [3] " ¿Teléfono rojo? Volamos hacia Moscú" ## [4] " (1964)" ## [5] " " ## ## [[68]] ## [1] "" " 68." ## [3] " La princesa Mononoke" " (1997)" ## [5] " " ## ## [[69]] ## [1] "" " 69." " Old Boy" ## [4] " (2003)" " " ## ## [[70]] ## [1] "" " 70." " Joker" ## [4] " (2019)" " " ## ## [[71]] ## [1] "" " 71." " Your Name." ## [4] " (2016)" " " ## ## [[72]] ## [1] "" " 72." " Coco" ## [4] " (2017)" " " ## ## [[73]] ## [1] "" ## [2] " 73." ## [3] " El caballero oscuro: La leyenda renace" ## [4] " (2012)" ## [5] " " ## ## [[74]] ## [1] "" " 74." ## [3] " Aliens: El regreso" " (1986)" ## [5] " " ## ## [[75]] ## [1] "" ## [2] " 75." ## [3] " Érase una vez en América" ## [4] " (1984)" ## [5] " " ## ## [[76]] ## [1] "" " 76." ## [3] " Vengadores: Endgame" " (2019)" ## [5] " " ## ## [[77]] ## [1] "" " 77." " Cafarnaúm" ## [4] " (2018)" " " ## ## [[78]] ## [1] "" ## [2] " 78." ## [3] " El submarino (Das Boot)" ## [4] " (1981)" ## [5] " " ## ## [[79]] ## [1] "" " 79." ## [3] " El infierno del odio" " (1963)" ## [5] " " ## ## [[80]] ## [1] "" " 80." " 3 Idiots" ## [4] " (2009)" " " ## ## [[81]] ## [1] "" " 81." " Toy Story" ## [4] " (1995)" " " ## ## [[82]] ## [1] "" " 82." " Amadeus" ## [4] " (1984)" " " ## ## [[83]] ## [1] "" " 83." ## [3] " American Beauty" " (1999)" ## [5] " " ## ## [[84]] ## [1] "" " 84." " Braveheart" ## [4] " (1995)" " " ## ## [[85]] ## [1] "" " 85." ## [3] " Malditos bastardos" " (2009)" ## [5] " " ## ## [[86]] ## [1] "" ## [2] " 86." ## [3] " El indomable Will Hunting" ## [4] " (1997)" ## [5] " " ## ## [[87]] ## [1] "" " 87." " Hamilton" ## [4] " (2020)" " " ## ## [[88]] ## [1] "" " 88." ## [3] " El retorno del jedi" " (1983)" ## [5] " " ## ## [[89]] ## [1] "" " 89." ## [3] " Masacre (Ven y mira)" " (1985)" ## [5] " " ## ## [[90]] ## [1] "" ## [2] " 90." ## [3] " 2001: Una odisea del espacio" ## [4] " (1968)" ## [5] " " ## ## [[91]] ## [1] "" " 91." ## [3] " Reservoir Dogs" " (1992)" ## [5] " " ## ## [[92]] ## [1] "" " 92." ## [3] " Taare Zameen Par" " (2007)" ## [5] " " ## ## [[93]] ## [1] "" ## [2] " 93." ## [3] " Vértigo (De entre los muertos)" ## [4] " (1958)" ## [5] " " ## ## [[94]] ## [1] "" ## [2] " 94." ## [3] " M, el vampiro de Düsseldorf" ## [4] " (1931)" ## [5] " " ## ## [[95]] ## [1] "" " 95." " La caza" ## [4] " (2012)" " " ## ## [[96]] ## [1] "" " 96." ## [3] " Ciudadano Kane" " (1941)" ## [5] " " ## ## [[97]] ## [1] "" " 97." ## [3] " Réquiem por un sueño" " (2000)" ## [5] " " ## ## [[98]] ## [1] "" ## [2] " 98." ## [3] " Cantando bajo la lluvia" ## [4] " (1952)" ## [5] " " ## ## [[99]] ## [1] "" ## [2] " 99." ## [3] " Con la muerte en los talones" ## [4] " (1959)" ## [5] " " ## ## [[100]] ## [1] "" " 100." ## [3] " ¡Olvídate de mí!" " (2004)" ## [5] " " ## ## [[101]] ## [1] "" " 101." ## [3] " Ikiru (Vivir)" " (1952)" ## [5] " " ## ## [[102]] ## [1] "" " 102." ## [3] " Ladrón de bicicletas" " (1948)" ## [5] " " ## ## [[103]] ## [1] "" " 103." ## [3] " Lawrence de Arabia" " (1962)" ## [5] " " ## ## [[104]] ## [1] "" " 104." " El chico" ## [4] " (1921)" " " ## ## [[105]] ## [1] "" " 105." ## [3] " La chaqueta metálica" " (1987)" ## [5] " " ## ## [[106]] ## [1] "" " 106." " Incendios" ## [4] " (2010)" " " ## ## [[107]] ## [1] "" " 107." " Dangal" ## [4] " (2016)" " " ## ## [[108]] ## [1] "" " 108." ## [3] " El apartamento" " (1960)" ## [5] " " ## ## [[109]] ## [1] "" " 109." " Perdición" ## [4] " (1944)" " " ## ## [[110]] ## [1] "" " 110." " Metrópolis" ## [4] " (1927)" " " ## ## [[111]] ## [1] "" " 111." " El padre" ## [4] " (2020)" " " ## ## [[112]] ## [1] "" ## [2] " 112." ## [3] " Nader y Simin, una separación" ## [4] " (2011)" ## [5] " " ## ## [[113]] ## [1] "" " 113." " Taxi Driver" ## [4] " (1976)" " " ## ## [[114]] ## [1] "" " 114." ## [3] " La naranja mecánica" " (1971)" ## [5] " " ## ## [[115]] ## [1] "" " 115." " El golpe" ## [4] " (1973)" " " ## ## [[116]] ## [1] "" " 116." ## [3] " El precio del poder" " (1983)" ## [5] " " ## ## [[117]] ## [1] "" ## [2] " 117." ## [3] " Snatch, cerdos y diamantes" ## [4] " (2000)" ## [5] " " ## ## [[118]] ## [1] "" " 118." " 1917" ## [4] " (2019)" " " ## ## [[119]] ## [1] "" " 119." " Amelie" ## [4] " (2001)" " " ## ## [[120]] ## [1] "" " 120." ## [3] " Matar a un ruiseñor" " (1962)" ## [5] " " ## ## [[121]] ## [1] "" " 121." " Toy Story 3" ## [4] " (2010)" " " ## ## [[122]] ## [1] "" ## [2] " 122." ## [3] " La muerte tenía un precio" ## [4] " (1965)" ## [5] " " ## ## [[123]] ## [1] "" ## [2] " 123." ## [3] " Pather Panchali (La canción del camino)" ## [4] " (1955)" ## [5] " " ## ## [[124]] ## [1] "" " 124." " Up" ## [4] " (2009)" " " ## ## [[125]] ## [1] "" ## [2] " 125." ## [3] " Indiana Jones y la última cruzada" ## [4] " (1989)" ## [5] " " ## ## [[126]] ## [1] "" " 126." " Heat" ## [4] " (1995)" " " ## ## [[127]] ## [1] "" " 127." ## [3] " L.A. Confidential" " (1997)" ## [5] " " ## ## [[128]] ## [1] "" " 128." " Ran" ## [4] " (1985)" " " ## ## [[129]] ## [1] "" " 129." " Yojimbo" ## [4] " (1961)" " " ## ## [[130]] ## [1] "" " 130." ## [3] " Jungla de cristal" " (1988)" ## [5] " " ## ## [[131]] ## [1] "" " 131." " Green Book" ## [4] " (2018)" " " ## ## [[132]] ## [1] "" " 132." " Rashomon" ## [4] " (1950)" " " ## ## [[133]] ## [1] "" " 133." ## [3] " El hundimiento" " (2004)" ## [5] " " ## ## [[134]] ## [1] "" " 134." ## [3] " Eva al desnudo" " (1950)" ## [5] " " ## ## [[135]] ## [1] "" ## [2] " 135." ## [3] " Los caballeros de la mesa cuadrada y sus locos seguidores" ## [4] " (1975)" ## [5] " " ## ## [[136]] ## [1] "" " 136." ## [3] " Con faldas y a lo loco" " (1959)" ## [5] " " ## ## [[137]] ## [1] "" " 137." ## [3] " Batman Begins" " (2005)" ## [5] " " ## ## [[138]] ## [1] "" " 138." " Sin perdón" ## [4] " (1992)" " " ## ## [[139]] ## [1] "" " 139." ## [3] " Children of Heaven" " (1997)" ## [5] " " ## ## [[140]] ## [1] "" " 140." " Jai Bhim" ## [4] " (2021)" " " ## ## [[141]] ## [1] "" " 141." ## [3] " El castillo ambulante" " (2004)" ## [5] " " ## ## [[142]] ## [1] "" " 142." ## [3] " El lobo de Wall Street" " (2013)" ## [5] " " ## ## [[143]] ## [1] "" " 143." ## [3] " Vencedores o vencidos" " (1961)" ## [5] " " ## ## [[144]] ## [1] "" " 144." ## [3] " Pozos de ambición" " (2007)" ## [5] " " ## ## [[145]] ## [1] "" " 145." ## [3] " La gran evasión" " (1963)" ## [5] " " ## ## [[146]] ## [1] "" " 146." " Casino" ## [4] " (1995)" " " ## ## [[147]] ## [1] "" ## [2] " 147." ## [3] " El tesoro de Sierra Madre" ## [4] " (1948)" ## [5] " " ## ## [[148]] ## [1] "" " 148." ## [3] " El laberinto del fauno" " (2006)" ## [5] " " ## ## [[149]] ## [1] "" " 149." ## [3] " Una mente maravillosa" " (2001)" ## [5] " " ## ## [[150]] ## [1] "" " 150." ## [3] " El secreto de sus ojos" " (2009)" ## [5] " " ## ## [[151]] ## [1] "" " 151." ## [3] " Toro salvaje" " (1980)" ## [5] " " ## ## [[152]] ## [1] "" " 152." " Chinatown" ## [4] " (1974)" " " ## ## [[153]] ## [1] "" " 153." ## [3] " Mi vecino Totoro" " (1988)" ## [5] " " ## ## [[154]] ## [1] "" " 154." ## [3] " Shutter Island" " (2010)" ## [5] " " ## ## [[155]] ## [1] "" " 155." ## [3] " Lock & Stock" " (1998)" ## [5] " " ## ## [[156]] ## [1] "" " 156." ## [3] " No es país para viejos" " (2007)" ## [5] " " ## ## [[157]] ## [1] "" " 157." " Klaus" ## [4] " (2019)" " " ## ## [[158]] ## [1] "" " 158." ## [3] " Crimen perfecto" " (1954)" ## [5] " " ## ## [[159]] ## [1] "" " 159." ## [3] " La quimera del oro" " (1925)" ## [5] " " ## ## [[160]] ## [1] "" " 160." " La cosa" ## [4] " (1982)" " " ## ## [[161]] ## [1] "" ## [2] " 161." ## [3] " Tres anuncios en las afueras" ## [4] " (2017)" ## [5] " " ## ## [[162]] ## [1] "" ## [2] " 162." ## [3] " Dersu Uzala (El cazador)" ## [4] " (1975)" ## [5] " " ## ## [[163]] ## [1] "" " 163." ## [3] " El séptimo sello" " (1957)" ## [5] " " ## ## [[164]] ## [1] "" " 164." ## [3] " El hombre elefante" " (1980)" ## [5] " " ## ## [[165]] ## [1] "" " 165." ## [3] " El sexto sentido" " (1999)" ## [5] " " ## ## [[166]] ## [1] "" " 166." ## [3] " El show de Truman" " (1998)" ## [5] " " ## ## [[167]] ## [1] "" ## [2] " 167." ## [3] " Jurassic Park (Parque Jurásico)" ## [4] " (1993)" ## [5] " " ## ## [[168]] ## [1] "" " 168." ## [3] " Fresas salvajes" " (1957)" ## [5] " " ## ## [[169]] ## [1] "" " 169." ## [3] " El tercer hombre" " (1949)" ## [5] " " ## ## [[170]] ## [1] "" ## [2] " 170." ## [3] " Memories of Murder (Crónica de un asesino en serie)" ## [4] " (2003)" ## [5] " " ## ## [[171]] ## [1] "" " 171." ## [3] " V de Vendetta" " (2005)" ## [5] " " ## ## [[172]] ## [1] "" " 172." ## [3] " Blade Runner" " (1982)" ## [5] " " ## ## [[173]] ## [1] "" " 173." ## [3] " Trainspotting" " (1996)" ## [5] " " ## ## [[174]] ## [1] "" " 174." " Fargo" ## [4] " (1996)" " " ## ## [[175]] ## [1] "" ## [2] " 175." ## [3] " El puente sobre el río Kwai" ## [4] " (1957)" ## [5] " " ## ## [[176]] ## [1] "" " 176." ## [3] " Del revés (Inside Out)" " (2015)" ## [5] " " ## ## [[177]] ## [1] "" " 177." ## [3] " Buscando a Nemo" " (2003)" ## [5] " " ## ## [[178]] ## [1] "" " 178." ## [3] " Kill Bill: Volumen 1" " (2003)" ## [5] " " ## ## [[179]] ## [1] "" " 179." " Warrior" ## [4] " (2011)" " " ## ## [[180]] ## [1] "" ## [2] " 180." ## [3] " Lo que el viento se llevó" ## [4] " (1939)" ## [5] " " ## ## [[181]] ## [1] "" " 181." ## [3] " Cuentos de Tokio" " (1953)" ## [5] " " ## ## [[182]] ## [1] "" " 182." ## [3] " La ley del silencio" " (1954)" ## [5] " " ## ## [[183]] ## [1] "" " 183." ## [3] " Mi padre y mi hijo" " (2005)" ## [5] " " ## ## [[184]] ## [1] "" " 184." ## [3] " Relatos salvajes" " (2014)" ## [5] " " ## ## [[185]] ## [1] "" " 185." " Prisioneros" ## [4] " (2013)" " " ## ## [[186]] ## [1] "" " 186." " Stalker" ## [4] " (1979)" " " ## ## [[187]] ## [1] "" " 187." ## [3] " El gran hotel Budapest" " (2014)" ## [5] " " ## ## [[188]] ## [1] "" " 188." " El cazador" ## [4] " (1978)" " " ## ## [[189]] ## [1] "" ## [2] " 189." ## [3] " El moderno Sherlock Holmes" ## [4] " (1924)" ## [5] " " ## ## [[190]] ## [1] "" ## [2] " 190." ## [3] " El maquinista de La General" ## [4] " (1926)" ## [5] " " ## ## [[191]] ## [1] "" " 191." " Gran Torino" ## [4] " (2008)" " " ## ## [[192]] ## [1] "" " 192." " Persona" ## [4] " (1966)" " " ## ## [[193]] ## [1] "" " 193." ## [3] " Antes de amanecer" " (1995)" ## [5] " " ## ## [[194]] ## [1] "" " 194." ## [3] " Mary and Max" " (2009)" ## [5] " " ## ## [[195]] ## [1] "" " 195." ## [3] " Atrápame si puedes" " (2002)" ## [5] " " ## ## [[196]] ## [1] "" " 196." " Dune" ## [4] " (2021)" " " ## ## [[197]] ## [1] "" " 197." ## [3] " Caballero sin espada" " (1939)" ## [5] " " ## ## [[198]] ## [1] "" " 198." ## [3] " Barry Lyndon" " (1975)" ## [5] " " ## ## [[199]] ## [1] "" " 199." " Z" ## [4] " (1969)" " " ## ## [[200]] ## [1] "" " 200." ## [3] " En el nombre del padre" " (1993)" ## [5] " " ## ## [[201]] ## [1] "" " 201." ## [3] " Hasta el último hombre" " (2016)" ## [5] " " ## ## [[202]] ## [1] "" " 202." " Perdida" ## [4] " (2014)" " " ## ## [[203]] ## [1] "" " 203." ## [3] " La habitación" " (2015)" ## [5] " " ## ## [[204]] ## [1] "" ## [2] " 204." ## [3] " La pasión de Juana de Arco" ## [4] " (1928)" ## [5] " " ## ## [[205]] ## [1] "" " 205." " Andhadhun" ## [4] " (2018)" " " ## ## [[206]] ## [1] "" " 206." " Le Mans '66" ## [4] " (2019)" " " ## ## [[207]] ## [1] "" " 207." ## [3] " 12 años de esclavitud" " (2013)" ## [5] " " ## ## [[208]] ## [1] "" " 208." ## [3] " Ser o no ser" " (1942)" ## [5] " " ## ## [[209]] ## [1] "" " 209." ## [3] " El gran Lebowski" " (1998)" ## [5] " " ## ## [[210]] ## [1] "" ## [2] " 210." ## [3] " El club de los poetas muertos" ## [4] " (1989)" ## [5] " " ## ## [[211]] ## [1] "" ## [2] " 211." ## [3] " Harry Potter y las Reliquias de la Muerte - Parte 2" ## [4] " (2011)" ## [5] " " ## ## [[212]] ## [1] "" " 212." " Ben-Hur" ## [4] " (1959)" " " ## ## [[213]] ## [1] "" ## [2] " 213." ## [3] " Cómo entrenar a tu dragón" ## [4] " (2010)" ## [5] " " ## ## [[214]] ## [1] "" ## [2] " 214." ## [3] " Mad Max: Furia en la carretera" ## [4] " (2015)" ## [5] " " ## ## [[215]] ## [1] "" " 215." ## [3] " Sonata de otoño" " (1978)" ## [5] " " ## ## [[216]] ## [1] "" " 216." ## [3] " Million Dollar Baby" " (2004)" ## [5] " " ## ## [[217]] ## [1] "" " 217." ## [3] " El salario del miedo" " (1953)" ## [5] " " ## ## [[218]] ## [1] "" " 218." ## [3] " Cuenta conmigo" " (1986)" ## [5] " " ## ## [[219]] ## [1] "" " 219." " La doncella" ## [4] " (2016)" " " ## ## [[220]] ## [1] "" ## [2] " 220." ## [3] " Network, un mundo implacable" ## [4] " (1976)" ## [5] " " ## ## [[221]] ## [1] "" " 221." " Logan" ## [4] " (2017)" " " ## ## [[222]] ## [1] "" " 222." " El odio" ## [4] " (1995)" " " ## ## [[223]] ## [1] "" " 223." ## [3] " A Silent Voice" " (2016)" ## [5] " " ## ## [[224]] ## [1] "" ## [2] " 224." ## [3] " La leyenda del indomable" ## [4] " (1967)" ## [5] " " ## ## [[225]] ## [1] "" ## [2] " 225." ## [3] " Siempre a tu lado (Hachiko)" ## [4] " (2009)" ## [5] " " ## ## [[226]] ## [1] "" " 226." ## [3] " Gangs of Wasseypur" " (2012)" ## [5] " " ## ## [[227]] ## [1] "" ## [2] " 227." ## [3] " Los cuatrocientos golpes" ## [4] " (1959)" ## [5] " " ## ## [[228]] ## [1] "" " 228." " Platoon" ## [4] " (1986)" " " ## ## [[229]] ## [1] "" " 229." " Spotlight" ## [4] " (2015)" " " ## ## [[230]] ## [1] "" " 230." ## [3] " Monstruos, S.A." " (2001)" ## [5] " " ## ## [[231]] ## [1] "" " 231." " Rebeca" ## [4] " (1940)" " " ## ## [[232]] ## [1] "" " 232." ## [3] " La vida de Brian" " (1979)" ## [5] " " ## ## [[233]] ## [1] "" " 233." ## [3] " Deseando amar" " (2000)" ## [5] " " ## ## [[234]] ## [1] "" " 234." ## [3] " Hotel Rwanda" " (2004)" ## [5] " " ## ## [[235]] ## [1] "" " 235." " Eskiya" ## [4] " (1996)" " " ## ## [[236]] ## [1] "" " 236." " Rush" ## [4] " (2013)" " " ## ## [[237]] ## [1] "" " 237." " Rocky" ## [4] " (1976)" " " ## ## [[238]] ## [1] "" " 238." ## [3] " Amores perros" " (2000)" ## [5] " " ## ## [[239]] ## [1] "" " 239." ## [3] " Hacia rutas salvajes" " (2007)" ## [5] " " ## ## [[240]] ## [1] "" ## [2] " 240." ## [3] " Nausicaä del Valle del Viento" ## [4] " (1984)" ## [5] " " ## ## [[241]] ## [1] "" " 241." ## [3] " Sucedió una noche" " (1934)" ## [5] " " ## ## [[242]] ## [1] "" " 242." ## [3] " Antes del atardecer" " (2004)" ## [5] " " ## ## [[243]] ## [1] "" " 243." ## [3] " Fanny y Alexander" " (1982)" ## [5] " " ## ## [[244]] ## [1] "" ## [2] " 244." ## [3] " Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito" ## [4] " (2020)" ## [5] " " ## ## [[245]] ## [1] "" " 245." ## [3] " La batalla de Argel" " (1966)" ## [5] " " ## ## [[246]] ## [1] "" " 246." ## [3] " Las noches de Cabiria" " (1957)" ## [5] " " ## ## [[247]] ## [1] "" " 247." " Drishyam" ## [4] " (2013)" " " ## ## [[248]] ## [1] "" " 248." ## [3] " Andrei Rublev" " (1966)" ## [5] " " ## ## [[249]] ## [1] "" ## [2] " 249." ## [3] " Neon Genesis Evangelion: The End of Evangelion" ## [4] " (1997)" ## [5] " " ## ## [[250]] ## [1] "" " 250." ## [3] " La princesa prometida" " (1987)" ## [5] " " ``` ] --- # ¿Cómo obtenemos el título de la película? .scrollable[ ```r titulos <- html_elements(datos, ".titleColumn") %>% html_text() %>% strsplit("\n") *sapply(1:250, function(i){titulos[[i]][3]}) ``` ``` ## [1] " Cadena perpetua" ## [2] " El padrino" ## [3] " El padrino: Parte II" ## [4] " El caballero oscuro" ## [5] " 12 hombres sin piedad" ## [6] " La lista de Schindler" ## [7] " El señor de los anillos: El retorno del rey" ## [8] " Pulp Fiction" ## [9] " El bueno, el feo y el malo" ## [10] " El señor de los anillos: La comunidad del anillo" ## [11] " El club de la lucha" ## [12] " Forrest Gump" ## [13] " Origen" ## [14] " El señor de los anillos: Las dos torres" ## [15] " El Imperio contraataca" ## [16] " Matrix" ## [17] " Uno de los nuestros" ## [18] " Alguien voló sobre el nido del cuco" ## [19] " Los siete samuráis" ## [20] " Seven" ## [21] " Spider-Man: No Way Home" ## [22] " El silencio de los corderos" ## [23] " Ciudad de Dios" ## [24] " ¡Qué bello es vivir!" ## [25] " La vida es bella" ## [26] " Salvar al soldado Ryan" ## [27] " La guerra de las galaxias" ## [28] " Interstellar" ## [29] " El viaje de Chihiro" ## [30] " La milla verde" ## [31] " Parásitos" ## [32] " El profesional (Léon)" ## [33] " Harakiri" ## [34] " El pianista" ## [35] " Terminator 2: El juicio final" ## [36] " Regreso al futuro" ## [37] " Sospechosos habituales" ## [38] " Psicosis" ## [39] " El rey león" ## [40] " Tiempos modernos" ## [41] " La tumba de las luciérnagas" ## [42] " American History X" ## [43] " Whiplash" ## [44] " Gladiator (El gladiador)" ## [45] " Luces de la ciudad" ## [46] " Infiltrados" ## [47] " Intocable" ## [48] " El truco final (El prestigio)" ## [49] " Casablanca" ## [50] " Hasta que llegó su hora" ## [51] " La ventana indiscreta" ## [52] " Cinema Paradiso" ## [53] " Alien, el octavo pasajero" ## [54] " Apocalypse Now" ## [55] " Memento" ## [56] " En busca del arca perdida" ## [57] " El gran dictador" ## [58] " Django desencadenado" ## [59] " La vida de los otros" ## [60] " Senderos de gloria" ## [61] " El crepúsculo de los dioses" ## [62] " WALL·E" ## [63] " Vengadores: Infinity War" ## [64] " Testigo de cargo" ## [65] " Spider-Man: Un nuevo universo" ## [66] " El resplandor" ## [67] " ¿Teléfono rojo? Volamos hacia Moscú" ## [68] " La princesa Mononoke" ## [69] " Old Boy" ## [70] " Joker" ## [71] " Your Name." ## [72] " Coco" ## [73] " El caballero oscuro: La leyenda renace" ## [74] " Aliens: El regreso" ## [75] " Érase una vez en América" ## [76] " Vengadores: Endgame" ## [77] " Cafarnaúm" ## [78] " El submarino (Das Boot)" ## [79] " El infierno del odio" ## [80] " 3 Idiots" ## [81] " Toy Story" ## [82] " Amadeus" ## [83] " American Beauty" ## [84] " Braveheart" ## [85] " Malditos bastardos" ## [86] " El indomable Will Hunting" ## [87] " Hamilton" ## [88] " El retorno del jedi" ## [89] " Masacre (Ven y mira)" ## [90] " 2001: Una odisea del espacio" ## [91] " Reservoir Dogs" ## [92] " Taare Zameen Par" ## [93] " Vértigo (De entre los muertos)" ## [94] " M, el vampiro de Düsseldorf" ## [95] " La caza" ## [96] " Ciudadano Kane" ## [97] " Réquiem por un sueño" ## [98] " Cantando bajo la lluvia" ## [99] " Con la muerte en los talones" ## [100] " ¡Olvídate de mí!" ## [101] " Ikiru (Vivir)" ## [102] " Ladrón de bicicletas" ## [103] " Lawrence de Arabia" ## [104] " El chico" ## [105] " La chaqueta metálica" ## [106] " Incendios" ## [107] " Dangal" ## [108] " El apartamento" ## [109] " Perdición" ## [110] " Metrópolis" ## [111] " El padre" ## [112] " Nader y Simin, una separación" ## [113] " Taxi Driver" ## [114] " La naranja mecánica" ## [115] " El golpe" ## [116] " El precio del poder" ## [117] " Snatch, cerdos y diamantes" ## [118] " 1917" ## [119] " Amelie" ## [120] " Matar a un ruiseñor" ## [121] " Toy Story 3" ## [122] " La muerte tenía un precio" ## [123] " Pather Panchali (La canción del camino)" ## [124] " Up" ## [125] " Indiana Jones y la última cruzada" ## [126] " Heat" ## [127] " L.A. Confidential" ## [128] " Ran" ## [129] " Yojimbo" ## [130] " Jungla de cristal" ## [131] " Green Book" ## [132] " Rashomon" ## [133] " El hundimiento" ## [134] " Eva al desnudo" ## [135] " Los caballeros de la mesa cuadrada y sus locos seguidores" ## [136] " Con faldas y a lo loco" ## [137] " Batman Begins" ## [138] " Sin perdón" ## [139] " Children of Heaven" ## [140] " Jai Bhim" ## [141] " El castillo ambulante" ## [142] " El lobo de Wall Street" ## [143] " Vencedores o vencidos" ## [144] " Pozos de ambición" ## [145] " La gran evasión" ## [146] " Casino" ## [147] " El tesoro de Sierra Madre" ## [148] " El laberinto del fauno" ## [149] " Una mente maravillosa" ## [150] " El secreto de sus ojos" ## [151] " Toro salvaje" ## [152] " Chinatown" ## [153] " Mi vecino Totoro" ## [154] " Shutter Island" ## [155] " Lock & Stock" ## [156] " No es país para viejos" ## [157] " Klaus" ## [158] " Crimen perfecto" ## [159] " La quimera del oro" ## [160] " La cosa" ## [161] " Tres anuncios en las afueras" ## [162] " Dersu Uzala (El cazador)" ## [163] " El séptimo sello" ## [164] " El hombre elefante" ## [165] " El sexto sentido" ## [166] " El show de Truman" ## [167] " Jurassic Park (Parque Jurásico)" ## [168] " Fresas salvajes" ## [169] " El tercer hombre" ## [170] " Memories of Murder (Crónica de un asesino en serie)" ## [171] " V de Vendetta" ## [172] " Blade Runner" ## [173] " Trainspotting" ## [174] " Fargo" ## [175] " El puente sobre el río Kwai" ## [176] " Del revés (Inside Out)" ## [177] " Buscando a Nemo" ## [178] " Kill Bill: Volumen 1" ## [179] " Warrior" ## [180] " Lo que el viento se llevó" ## [181] " Cuentos de Tokio" ## [182] " La ley del silencio" ## [183] " Mi padre y mi hijo" ## [184] " Relatos salvajes" ## [185] " Prisioneros" ## [186] " Stalker" ## [187] " El gran hotel Budapest" ## [188] " El cazador" ## [189] " El moderno Sherlock Holmes" ## [190] " El maquinista de La General" ## [191] " Gran Torino" ## [192] " Persona" ## [193] " Antes de amanecer" ## [194] " Mary and Max" ## [195] " Atrápame si puedes" ## [196] " Dune" ## [197] " Caballero sin espada" ## [198] " Barry Lyndon" ## [199] " Z" ## [200] " En el nombre del padre" ## [201] " Hasta el último hombre" ## [202] " Perdida" ## [203] " La habitación" ## [204] " La pasión de Juana de Arco" ## [205] " Andhadhun" ## [206] " Le Mans '66" ## [207] " 12 años de esclavitud" ## [208] " Ser o no ser" ## [209] " El gran Lebowski" ## [210] " El club de los poetas muertos" ## [211] " Harry Potter y las Reliquias de la Muerte - Parte 2" ## [212] " Ben-Hur" ## [213] " Cómo entrenar a tu dragón" ## [214] " Mad Max: Furia en la carretera" ## [215] " Sonata de otoño" ## [216] " Million Dollar Baby" ## [217] " El salario del miedo" ## [218] " Cuenta conmigo" ## [219] " La doncella" ## [220] " Network, un mundo implacable" ## [221] " Logan" ## [222] " El odio" ## [223] " A Silent Voice" ## [224] " La leyenda del indomable" ## [225] " Siempre a tu lado (Hachiko)" ## [226] " Gangs of Wasseypur" ## [227] " Los cuatrocientos golpes" ## [228] " Platoon" ## [229] " Spotlight" ## [230] " Monstruos, S.A." ## [231] " Rebeca" ## [232] " La vida de Brian" ## [233] " Deseando amar" ## [234] " Hotel Rwanda" ## [235] " Eskiya" ## [236] " Rush" ## [237] " Rocky" ## [238] " Amores perros" ## [239] " Hacia rutas salvajes" ## [240] " Nausicaä del Valle del Viento" ## [241] " Sucedió una noche" ## [242] " Antes del atardecer" ## [243] " Fanny y Alexander" ## [244] " Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito" ## [245] " La batalla de Argel" ## [246] " Las noches de Cabiria" ## [247] " Drishyam" ## [248] " Andrei Rublev" ## [249] " Neon Genesis Evangelion: The End of Evangelion" ## [250] " La princesa prometida" ``` ] --- # ¿Cómo obtenemos el título de la película? .scrollable[ ```r titulos <- html_elements(datos, ".titleColumn") %>% html_text() %>% strsplit("\n") movies <- sapply(1:250, function(i){titulos[[i]][3]}) %>% * trimws() *movies ``` ``` ## [1] "Cadena perpetua" ## [2] "El padrino" ## [3] "El padrino: Parte II" ## [4] "El caballero oscuro" ## [5] "12 hombres sin piedad" ## [6] "La lista de Schindler" ## [7] "El señor de los anillos: El retorno del rey" ## [8] "Pulp Fiction" ## [9] "El bueno, el feo y el malo" ## [10] "El señor de los anillos: La comunidad del anillo" ## [11] "El club de la lucha" ## [12] "Forrest Gump" ## [13] "Origen" ## [14] "El señor de los anillos: Las dos torres" ## [15] "El Imperio contraataca" ## [16] "Matrix" ## [17] "Uno de los nuestros" ## [18] "Alguien voló sobre el nido del cuco" ## [19] "Los siete samuráis" ## [20] "Seven" ## [21] "Spider-Man: No Way Home" ## [22] "El silencio de los corderos" ## [23] "Ciudad de Dios" ## [24] "¡Qué bello es vivir!" ## [25] "La vida es bella" ## [26] "Salvar al soldado Ryan" ## [27] "La guerra de las galaxias" ## [28] "Interstellar" ## [29] "El viaje de Chihiro" ## [30] "La milla verde" ## [31] "Parásitos" ## [32] "El profesional (Léon)" ## [33] "Harakiri" ## [34] "El pianista" ## [35] "Terminator 2: El juicio final" ## [36] "Regreso al futuro" ## [37] "Sospechosos habituales" ## [38] "Psicosis" ## [39] "El rey león" ## [40] "Tiempos modernos" ## [41] "La tumba de las luciérnagas" ## [42] "American History X" ## [43] "Whiplash" ## [44] "Gladiator (El gladiador)" ## [45] "Luces de la ciudad" ## [46] "Infiltrados" ## [47] "Intocable" ## [48] "El truco final (El prestigio)" ## [49] "Casablanca" ## [50] "Hasta que llegó su hora" ## [51] "La ventana indiscreta" ## [52] "Cinema Paradiso" ## [53] "Alien, el octavo pasajero" ## [54] "Apocalypse Now" ## [55] "Memento" ## [56] "En busca del arca perdida" ## [57] "El gran dictador" ## [58] "Django desencadenado" ## [59] "La vida de los otros" ## [60] "Senderos de gloria" ## [61] "El crepúsculo de los dioses" ## [62] "WALL·E" ## [63] "Vengadores: Infinity War" ## [64] "Testigo de cargo" ## [65] "Spider-Man: Un nuevo universo" ## [66] "El resplandor" ## [67] "¿Teléfono rojo? Volamos hacia Moscú" ## [68] "La princesa Mononoke" ## [69] "Old Boy" ## [70] "Joker" ## [71] "Your Name." ## [72] "Coco" ## [73] "El caballero oscuro: La leyenda renace" ## [74] "Aliens: El regreso" ## [75] "Érase una vez en América" ## [76] "Vengadores: Endgame" ## [77] "Cafarnaúm" ## [78] "El submarino (Das Boot)" ## [79] "El infierno del odio" ## [80] "3 Idiots" ## [81] "Toy Story" ## [82] "Amadeus" ## [83] "American Beauty" ## [84] "Braveheart" ## [85] "Malditos bastardos" ## [86] "El indomable Will Hunting" ## [87] "Hamilton" ## [88] "El retorno del jedi" ## [89] "Masacre (Ven y mira)" ## [90] "2001: Una odisea del espacio" ## [91] "Reservoir Dogs" ## [92] "Taare Zameen Par" ## [93] "Vértigo (De entre los muertos)" ## [94] "M, el vampiro de Düsseldorf" ## [95] "La caza" ## [96] "Ciudadano Kane" ## [97] "Réquiem por un sueño" ## [98] "Cantando bajo la lluvia" ## [99] "Con la muerte en los talones" ## [100] "¡Olvídate de mí!" ## [101] "Ikiru (Vivir)" ## [102] "Ladrón de bicicletas" ## [103] "Lawrence de Arabia" ## [104] "El chico" ## [105] "La chaqueta metálica" ## [106] "Incendios" ## [107] "Dangal" ## [108] "El apartamento" ## [109] "Perdición" ## [110] "Metrópolis" ## [111] "El padre" ## [112] "Nader y Simin, una separación" ## [113] "Taxi Driver" ## [114] "La naranja mecánica" ## [115] "El golpe" ## [116] "El precio del poder" ## [117] "Snatch, cerdos y diamantes" ## [118] "1917" ## [119] "Amelie" ## [120] "Matar a un ruiseñor" ## [121] "Toy Story 3" ## [122] "La muerte tenía un precio" ## [123] "Pather Panchali (La canción del camino)" ## [124] "Up" ## [125] "Indiana Jones y la última cruzada" ## [126] "Heat" ## [127] "L.A. Confidential" ## [128] "Ran" ## [129] "Yojimbo" ## [130] "Jungla de cristal" ## [131] "Green Book" ## [132] "Rashomon" ## [133] "El hundimiento" ## [134] "Eva al desnudo" ## [135] "Los caballeros de la mesa cuadrada y sus locos seguidores" ## [136] "Con faldas y a lo loco" ## [137] "Batman Begins" ## [138] "Sin perdón" ## [139] "Children of Heaven" ## [140] "Jai Bhim" ## [141] "El castillo ambulante" ## [142] "El lobo de Wall Street" ## [143] "Vencedores o vencidos" ## [144] "Pozos de ambición" ## [145] "La gran evasión" ## [146] "Casino" ## [147] "El tesoro de Sierra Madre" ## [148] "El laberinto del fauno" ## [149] "Una mente maravillosa" ## [150] "El secreto de sus ojos" ## [151] "Toro salvaje" ## [152] "Chinatown" ## [153] "Mi vecino Totoro" ## [154] "Shutter Island" ## [155] "Lock & Stock" ## [156] "No es país para viejos" ## [157] "Klaus" ## [158] "Crimen perfecto" ## [159] "La quimera del oro" ## [160] "La cosa" ## [161] "Tres anuncios en las afueras" ## [162] "Dersu Uzala (El cazador)" ## [163] "El séptimo sello" ## [164] "El hombre elefante" ## [165] "El sexto sentido" ## [166] "El show de Truman" ## [167] "Jurassic Park (Parque Jurásico)" ## [168] "Fresas salvajes" ## [169] "El tercer hombre" ## [170] "Memories of Murder (Crónica de un asesino en serie)" ## [171] "V de Vendetta" ## [172] "Blade Runner" ## [173] "Trainspotting" ## [174] "Fargo" ## [175] "El puente sobre el río Kwai" ## [176] "Del revés (Inside Out)" ## [177] "Buscando a Nemo" ## [178] "Kill Bill: Volumen 1" ## [179] "Warrior" ## [180] "Lo que el viento se llevó" ## [181] "Cuentos de Tokio" ## [182] "La ley del silencio" ## [183] "Mi padre y mi hijo" ## [184] "Relatos salvajes" ## [185] "Prisioneros" ## [186] "Stalker" ## [187] "El gran hotel Budapest" ## [188] "El cazador" ## [189] "El moderno Sherlock Holmes" ## [190] "El maquinista de La General" ## [191] "Gran Torino" ## [192] "Persona" ## [193] "Antes de amanecer" ## [194] "Mary and Max" ## [195] "Atrápame si puedes" ## [196] "Dune" ## [197] "Caballero sin espada" ## [198] "Barry Lyndon" ## [199] "Z" ## [200] "En el nombre del padre" ## [201] "Hasta el último hombre" ## [202] "Perdida" ## [203] "La habitación" ## [204] "La pasión de Juana de Arco" ## [205] "Andhadhun" ## [206] "Le Mans '66" ## [207] "12 años de esclavitud" ## [208] "Ser o no ser" ## [209] "El gran Lebowski" ## [210] "El club de los poetas muertos" ## [211] "Harry Potter y las Reliquias de la Muerte - Parte 2" ## [212] "Ben-Hur" ## [213] "Cómo entrenar a tu dragón" ## [214] "Mad Max: Furia en la carretera" ## [215] "Sonata de otoño" ## [216] "Million Dollar Baby" ## [217] "El salario del miedo" ## [218] "Cuenta conmigo" ## [219] "La doncella" ## [220] "Network, un mundo implacable" ## [221] "Logan" ## [222] "El odio" ## [223] "A Silent Voice" ## [224] "La leyenda del indomable" ## [225] "Siempre a tu lado (Hachiko)" ## [226] "Gangs of Wasseypur" ## [227] "Los cuatrocientos golpes" ## [228] "Platoon" ## [229] "Spotlight" ## [230] "Monstruos, S.A." ## [231] "Rebeca" ## [232] "La vida de Brian" ## [233] "Deseando amar" ## [234] "Hotel Rwanda" ## [235] "Eskiya" ## [236] "Rush" ## [237] "Rocky" ## [238] "Amores perros" ## [239] "Hacia rutas salvajes" ## [240] "Nausicaä del Valle del Viento" ## [241] "Sucedió una noche" ## [242] "Antes del atardecer" ## [243] "Fanny y Alexander" ## [244] "Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito" ## [245] "La batalla de Argel" ## [246] "Las noches de Cabiria" ## [247] "Drishyam" ## [248] "Andrei Rublev" ## [249] "Neon Genesis Evangelion: The End of Evangelion" ## [250] "La princesa prometida" ``` ] --- # ¿Cómo obtenemos el año de lanzamiento? .scrollable[ ```r titulos <- html_elements(datos, ".titleColumn") %>% html_text() %>% strsplit("\n") *sapply(1:250, function(i){titulos[[i]][4]}) %>% * trimws() ``` ``` ## [1] "(1994)" "(1972)" "(1974)" "(2008)" "(1957)" "(1993)" ## [7] "(2003)" "(1994)" "(1966)" "(2001)" "(1999)" "(1994)" ## [13] "(2010)" "(2002)" "(1980)" "(1999)" "(1990)" "(1975)" ## [19] "(1954)" "(1995)" "(2021)" "(1991)" "(2002)" "(1946)" ## [25] "(1997)" "(1998)" "(1977)" "(2014)" "(2001)" "(1999)" ## [31] "(2019)" "(1994)" "(1962)" "(2002)" "(1991)" "(1985)" ## [37] "(1995)" "(1960)" "(1994)" "(1936)" "(1988)" "(1998)" ## [43] "(2014)" "(2000)" "(1931)" "(2006)" "(2011)" "(2006)" ## [49] "(1942)" "(1968)" "(1954)" "(1988)" "(1979)" "(1979)" ## [55] "(2000)" "(1981)" "(1940)" "(2012)" "(2006)" "(1957)" ## [61] "(1950)" "(2008)" "(2018)" "(1957)" "(2018)" "(1980)" ## [67] "(1964)" "(1997)" "(2003)" "(2019)" "(2016)" "(2017)" ## [73] "(2012)" "(1986)" "(1984)" "(2019)" "(2018)" "(1981)" ## [79] "(1963)" "(2009)" "(1995)" "(1984)" "(1999)" "(1995)" ## [85] "(2009)" "(1997)" "(2020)" "(1983)" "(1985)" "(1968)" ## [91] "(1992)" "(2007)" "(1958)" "(1931)" "(2012)" "(1941)" ## [97] "(2000)" "(1952)" "(1959)" "(2004)" "(1952)" "(1948)" ## [103] "(1962)" "(1921)" "(1987)" "(2010)" "(2016)" "(1960)" ## [109] "(1944)" "(1927)" "(2020)" "(2011)" "(1976)" "(1971)" ## [115] "(1973)" "(1983)" "(2000)" "(2019)" "(2001)" "(1962)" ## [121] "(2010)" "(1965)" "(1955)" "(2009)" "(1989)" "(1995)" ## [127] "(1997)" "(1985)" "(1961)" "(1988)" "(2018)" "(1950)" ## [133] "(2004)" "(1950)" "(1975)" "(1959)" "(2005)" "(1992)" ## [139] "(1997)" "(2021)" "(2004)" "(2013)" "(1961)" "(2007)" ## [145] "(1963)" "(1995)" "(1948)" "(2006)" "(2001)" "(2009)" ## [151] "(1980)" "(1974)" "(1988)" "(2010)" "(1998)" "(2007)" ## [157] "(2019)" "(1954)" "(1925)" "(1982)" "(2017)" "(1975)" ## [163] "(1957)" "(1980)" "(1999)" "(1998)" "(1993)" "(1957)" ## [169] "(1949)" "(2003)" "(2005)" "(1982)" "(1996)" "(1996)" ## [175] "(1957)" "(2015)" "(2003)" "(2003)" "(2011)" "(1939)" ## [181] "(1953)" "(1954)" "(2005)" "(2014)" "(2013)" "(1979)" ## [187] "(2014)" "(1978)" "(1924)" "(1926)" "(2008)" "(1966)" ## [193] "(1995)" "(2009)" "(2002)" "(2021)" "(1939)" "(1975)" ## [199] "(1969)" "(1993)" "(2016)" "(2014)" "(2015)" "(1928)" ## [205] "(2018)" "(2019)" "(2013)" "(1942)" "(1998)" "(1989)" ## [211] "(2011)" "(1959)" "(2010)" "(2015)" "(1978)" "(2004)" ## [217] "(1953)" "(1986)" "(2016)" "(1976)" "(2017)" "(1995)" ## [223] "(2016)" "(1967)" "(2009)" "(2012)" "(1959)" "(1986)" ## [229] "(2015)" "(2001)" "(1940)" "(1979)" "(2000)" "(2004)" ## [235] "(1996)" "(2013)" "(1976)" "(2000)" "(2007)" "(1984)" ## [241] "(1934)" "(2004)" "(1982)" "(2020)" "(1966)" "(1957)" ## [247] "(2013)" "(1966)" "(1997)" "(1987)" ``` ] --- # ¿Cómo obtenemos el año de lanzamiento? .scrollable[ ```r titulos <- html_elements(datos, ".titleColumn") %>% html_text() %>% strsplit("\n") sapply(1:250, function(i){titulos[[i]][4]}) %>% trimws() %>% * gsub(pattern = "\\(|\\)", replacement = "") ``` ``` ## [1] "1994" "1972" "1974" "2008" "1957" "1993" "2003" "1994" ## [9] "1966" "2001" "1999" "1994" "2010" "2002" "1980" "1999" ## [17] "1990" "1975" "1954" "1995" "2021" "1991" "2002" "1946" ## [25] "1997" "1998" "1977" "2014" "2001" "1999" "2019" "1994" ## [33] "1962" "2002" "1991" "1985" "1995" "1960" "1994" "1936" ## [41] "1988" "1998" "2014" "2000" "1931" "2006" "2011" "2006" ## [49] "1942" "1968" "1954" "1988" "1979" "1979" "2000" "1981" ## [57] "1940" "2012" "2006" "1957" "1950" "2008" "2018" "1957" ## [65] "2018" "1980" "1964" "1997" "2003" "2019" "2016" "2017" ## [73] "2012" "1986" "1984" "2019" "2018" "1981" "1963" "2009" ## [81] "1995" "1984" "1999" "1995" "2009" "1997" "2020" "1983" ## [89] "1985" "1968" "1992" "2007" "1958" "1931" "2012" "1941" ## [97] "2000" "1952" "1959" "2004" "1952" "1948" "1962" "1921" ## [105] "1987" "2010" "2016" "1960" "1944" "1927" "2020" "2011" ## [113] "1976" "1971" "1973" "1983" "2000" "2019" "2001" "1962" ## [121] "2010" "1965" "1955" "2009" "1989" "1995" "1997" "1985" ## [129] "1961" "1988" "2018" "1950" "2004" "1950" "1975" "1959" ## [137] "2005" "1992" "1997" "2021" "2004" "2013" "1961" "2007" ## [145] "1963" "1995" "1948" "2006" "2001" "2009" "1980" "1974" ## [153] "1988" "2010" "1998" "2007" "2019" "1954" "1925" "1982" ## [161] "2017" "1975" "1957" "1980" "1999" "1998" "1993" "1957" ## [169] "1949" "2003" "2005" "1982" "1996" "1996" "1957" "2015" ## [177] "2003" "2003" "2011" "1939" "1953" "1954" "2005" "2014" ## [185] "2013" "1979" "2014" "1978" "1924" "1926" "2008" "1966" ## [193] "1995" "2009" "2002" "2021" "1939" "1975" "1969" "1993" ## [201] "2016" "2014" "2015" "1928" "2018" "2019" "2013" "1942" ## [209] "1998" "1989" "2011" "1959" "2010" "2015" "1978" "2004" ## [217] "1953" "1986" "2016" "1976" "2017" "1995" "2016" "1967" ## [225] "2009" "2012" "1959" "1986" "2015" "2001" "1940" "1979" ## [233] "2000" "2004" "1996" "2013" "1976" "2000" "2007" "1984" ## [241] "1934" "2004" "1982" "2020" "1966" "1957" "2013" "1966" ## [249] "1997" "1987" ``` ] --- # ¿Cómo obtenemos el año de lanzamiento? .scrollable[ ```r titulos <- html_elements(datos, ".titleColumn") %>% html_text() %>% strsplit("\n") year <- sapply(1:250, function(i){titulos[[i]][4]}) %>% trimws() %>% gsub(pattern = "\\(|\\)", replacement = "") %>% * as.numeric() *year ``` ``` ## [1] 1994 1972 1974 2008 1957 1993 2003 1994 1966 2001 1999 1994 ## [13] 2010 2002 1980 1999 1990 1975 1954 1995 2021 1991 2002 1946 ## [25] 1997 1998 1977 2014 2001 1999 2019 1994 1962 2002 1991 1985 ## [37] 1995 1960 1994 1936 1988 1998 2014 2000 1931 2006 2011 2006 ## [49] 1942 1968 1954 1988 1979 1979 2000 1981 1940 2012 2006 1957 ## [61] 1950 2008 2018 1957 2018 1980 1964 1997 2003 2019 2016 2017 ## [73] 2012 1986 1984 2019 2018 1981 1963 2009 1995 1984 1999 1995 ## [85] 2009 1997 2020 1983 1985 1968 1992 2007 1958 1931 2012 1941 ## [97] 2000 1952 1959 2004 1952 1948 1962 1921 1987 2010 2016 1960 ## [109] 1944 1927 2020 2011 1976 1971 1973 1983 2000 2019 2001 1962 ## [121] 2010 1965 1955 2009 1989 1995 1997 1985 1961 1988 2018 1950 ## [133] 2004 1950 1975 1959 2005 1992 1997 2021 2004 2013 1961 2007 ## [145] 1963 1995 1948 2006 2001 2009 1980 1974 1988 2010 1998 2007 ## [157] 2019 1954 1925 1982 2017 1975 1957 1980 1999 1998 1993 1957 ## [169] 1949 2003 2005 1982 1996 1996 1957 2015 2003 2003 2011 1939 ## [181] 1953 1954 2005 2014 2013 1979 2014 1978 1924 1926 2008 1966 ## [193] 1995 2009 2002 2021 1939 1975 1969 1993 2016 2014 2015 1928 ## [205] 2018 2019 2013 1942 1998 1989 2011 1959 2010 2015 1978 2004 ## [217] 1953 1986 2016 1976 2017 1995 2016 1967 2009 2012 1959 1986 ## [229] 2015 2001 1940 1979 2000 2004 1996 2013 1976 2000 2007 1984 ## [241] 1934 2004 1982 2020 1966 1957 2013 1966 1997 1987 ``` ] --- # ¿Cómo obtenemos la puntuación? .scrollable[ ```r rates <- html_elements(datos, ".imdbRating") %>% html_text() %>% trimws() %>% as.numeric() rates ``` ``` ## [1] 9.2 9.1 9.0 9.0 8.9 8.9 8.9 8.8 8.8 8.8 8.7 8.7 8.7 8.7 8.7 ## [16] 8.7 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.6 8.5 8.5 8.5 8.5 ## [31] 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 8.5 ## [46] 8.5 8.5 8.5 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.4 ## [61] 8.4 8.4 8.4 8.4 8.4 8.4 8.4 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 ## [76] 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 ## [91] 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.3 8.2 8.2 ## [106] 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 ## [121] 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 ## [136] 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.2 8.1 8.1 8.1 ## [151] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [166] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [181] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [196] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 ## [211] 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.1 8.0 8.0 8.0 ## [226] 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 ## [241] 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 8.0 ``` ] --- # ¿Cómo obtenemos la popularidad (número de usuarios)? .scrollable[ ```r *html_elements(datos, ".imdbRating") %>% * as.character() ``` ``` ## [1] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"9.2 based on 2,531,700 user ratings\">9.2</strong>\n </td>" ## [2] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"9.1 based on 1,742,891 user ratings\">9.1</strong>\n </td>" ## [3] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"9.0 based on 1,209,198 user ratings\">9.0</strong>\n </td>" ## [4] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"9.0 based on 2,482,152 user ratings\">9.0</strong>\n </td>" ## [5] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.9 based on 748,065 user ratings\">8.9</strong>\n </td>" ## [6] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.9 based on 1,293,509 user ratings\">8.9</strong>\n </td>" ## [7] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.9 based on 1,747,018 user ratings\">8.9</strong>\n </td>" ## [8] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.8 based on 1,949,998 user ratings\">8.8</strong>\n </td>" ## [9] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.8 based on 731,614 user ratings\">8.8</strong>\n </td>" ## [10] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.8 based on 1,768,396 user ratings\">8.8</strong>\n </td>" ## [11] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.7 based on 1,991,339 user ratings\">8.7</strong>\n </td>" ## [12] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.7 based on 1,953,976 user ratings\">8.7</strong>\n </td>" ## [13] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.7 based on 2,224,763 user ratings\">8.7</strong>\n </td>" ## [14] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.7 based on 1,578,445 user ratings\">8.7</strong>\n </td>" ## [15] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.7 based on 1,229,090 user ratings\">8.7</strong>\n </td>" ## [16] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.7 based on 1,826,876 user ratings\">8.7</strong>\n </td>" ## [17] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 1,095,102 user ratings\">8.6</strong>\n </td>" ## [18] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 969,761 user ratings\">8.6</strong>\n </td>" ## [19] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 334,541 user ratings\">8.6</strong>\n </td>" ## [20] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 1,553,428 user ratings\">8.6</strong>\n </td>" ## [21] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 412,230 user ratings\">8.6</strong>\n </td>" ## [22] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 1,361,143 user ratings\">8.6</strong>\n </td>" ## [23] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 732,467 user ratings\">8.6</strong>\n </td>" ## [24] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 438,390 user ratings\">8.6</strong>\n </td>" ## [25] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 665,547 user ratings\">8.6</strong>\n </td>" ## [26] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.6 based on 1,321,592 user ratings\">8.6</strong>\n </td>" ## [27] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,300,609 user ratings\">8.5</strong>\n </td>" ## [28] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,677,437 user ratings\">8.5</strong>\n </td>" ## [29] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 714,107 user ratings\">8.5</strong>\n </td>" ## [30] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,231,748 user ratings\">8.5</strong>\n </td>" ## [31] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 709,314 user ratings\">8.5</strong>\n </td>" ## [32] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,106,314 user ratings\">8.5</strong>\n </td>" ## [33] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 51,721 user ratings\">8.5</strong>\n </td>" ## [34] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 789,182 user ratings\">8.5</strong>\n </td>" ## [35] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,052,376 user ratings\">8.5</strong>\n </td>" ## [36] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,138,876 user ratings\">8.5</strong>\n </td>" ## [37] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,046,304 user ratings\">8.5</strong>\n </td>" ## [38] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 643,322 user ratings\">8.5</strong>\n </td>" ## [39] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,005,098 user ratings\">8.5</strong>\n </td>" ## [40] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 233,246 user ratings\">8.5</strong>\n </td>" ## [41] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 259,944 user ratings\">8.5</strong>\n </td>" ## [42] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,082,985 user ratings\">8.5</strong>\n </td>" ## [43] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 786,708 user ratings\">8.5</strong>\n </td>" ## [44] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,429,325 user ratings\">8.5</strong>\n </td>" ## [45] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 179,056 user ratings\">8.5</strong>\n </td>" ## [46] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,265,213 user ratings\">8.5</strong>\n </td>" ## [47] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 815,790 user ratings\">8.5</strong>\n </td>" ## [48] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.5 based on 1,271,569 user ratings\">8.5</strong>\n </td>" ## [49] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 551,891 user ratings\">8.4</strong>\n </td>" ## [50] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 319,396 user ratings\">8.4</strong>\n </td>" ## [51] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 473,904 user ratings\">8.4</strong>\n </td>" ## [52] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 250,455 user ratings\">8.4</strong>\n </td>" ## [53] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 840,139 user ratings\">8.4</strong>\n </td>" ## [54] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 641,438 user ratings\">8.4</strong>\n </td>" ## [55] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 1,189,688 user ratings\">8.4</strong>\n </td>" ## [56] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 931,623 user ratings\">8.4</strong>\n </td>" ## [57] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 216,945 user ratings\">8.4</strong>\n </td>" ## [58] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 1,463,753 user ratings\">8.4</strong>\n </td>" ## [59] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 378,535 user ratings\">8.4</strong>\n </td>" ## [60] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 190,431 user ratings\">8.4</strong>\n </td>" ## [61] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 214,640 user ratings\">8.4</strong>\n </td>" ## [62] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 1,064,290 user ratings\">8.4</strong>\n </td>" ## [63] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 972,106 user ratings\">8.4</strong>\n </td>" ## [64] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 119,706 user ratings\">8.4</strong>\n </td>" ## [65] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 464,284 user ratings\">8.4</strong>\n </td>" ## [66] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 966,871 user ratings\">8.4</strong>\n </td>" ## [67] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.4 based on 474,230 user ratings\">8.4</strong>\n </td>" ## [68] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 373,966 user ratings\">8.3</strong>\n </td>" ## [69] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 552,568 user ratings\">8.3</strong>\n </td>" ## [70] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 1,132,183 user ratings\">8.3</strong>\n </td>" ## [71] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 238,093 user ratings\">8.3</strong>\n </td>" ## [72] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 456,615 user ratings\">8.3</strong>\n </td>" ## [73] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 1,610,958 user ratings\">8.3</strong>\n </td>" ## [74] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 690,362 user ratings\">8.3</strong>\n </td>" ## [75] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 336,927 user ratings\">8.3</strong>\n </td>" ## [76] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 1,000,782 user ratings\">8.3</strong>\n </td>" ## [77] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 80,736 user ratings\">8.3</strong>\n </td>" ## [78] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 244,173 user ratings\">8.3</strong>\n </td>" ## [79] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 41,343 user ratings\">8.3</strong>\n </td>" ## [80] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 376,773 user ratings\">8.3</strong>\n </td>" ## [81] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 946,338 user ratings\">8.3</strong>\n </td>" ## [82] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 388,247 user ratings\">8.3</strong>\n </td>" ## [83] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 1,119,463 user ratings\">8.3</strong>\n </td>" ## [84] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 1,003,644 user ratings\">8.3</strong>\n </td>" ## [85] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 1,365,916 user ratings\">8.3</strong>\n </td>" ## [86] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 920,815 user ratings\">8.3</strong>\n </td>" ## [87] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 81,385 user ratings\">8.3</strong>\n </td>" ## [88] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 1,004,735 user ratings\">8.3</strong>\n </td>" ## [89] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 71,458 user ratings\">8.3</strong>\n </td>" ## [90] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 641,827 user ratings\">8.3</strong>\n </td>" ## [91] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 975,499 user ratings\">8.3</strong>\n </td>" ## [92] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 184,733 user ratings\">8.3</strong>\n </td>" ## [93] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 389,148 user ratings\">8.3</strong>\n </td>" ## [94] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 153,172 user ratings\">8.3</strong>\n </td>" ## [95] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 312,416 user ratings\">8.3</strong>\n </td>" ## [96] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 428,996 user ratings\">8.3</strong>\n </td>" ## [97] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 808,322 user ratings\">8.3</strong>\n </td>" ## [98] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 233,320 user ratings\">8.3</strong>\n </td>" ## [99] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 317,597 user ratings\">8.3</strong>\n </td>" ## [100] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 965,057 user ratings\">8.3</strong>\n </td>" ## [101] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 75,365 user ratings\">8.3</strong>\n </td>" ## [102] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 158,432 user ratings\">8.3</strong>\n </td>" ## [103] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.3 based on 284,236 user ratings\">8.3</strong>\n </td>" ## [104] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 122,576 user ratings\">8.2</strong>\n </td>" ## [105] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 713,333 user ratings\">8.2</strong>\n </td>" ## [106] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 167,993 user ratings\">8.2</strong>\n </td>" ## [107] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 177,104 user ratings\">8.2</strong>\n </td>" ## [108] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 175,448 user ratings\">8.2</strong>\n </td>" ## [109] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 152,262 user ratings\">8.2</strong>\n </td>" ## [110] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 169,424 user ratings\">8.2</strong>\n </td>" ## [111] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 120,085 user ratings\">8.2</strong>\n </td>" ## [112] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 236,017 user ratings\">8.2</strong>\n </td>" ## [113] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 779,371 user ratings\">8.2</strong>\n </td>" ## [114] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 798,908 user ratings\">8.2</strong>\n </td>" ## [115] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 254,194 user ratings\">8.2</strong>\n </td>" ## [116] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 795,535 user ratings\">8.2</strong>\n </td>" ## [117] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 825,488 user ratings\">8.2</strong>\n </td>" ## [118] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 526,049 user ratings\">8.2</strong>\n </td>" ## [119] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 734,458 user ratings\">8.2</strong>\n </td>" ## [120] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 308,205 user ratings\">8.2</strong>\n </td>" ## [121] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 800,434 user ratings\">8.2</strong>\n </td>" ## [122] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 247,853 user ratings\">8.2</strong>\n </td>" ## [123] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 30,222 user ratings\">8.2</strong>\n </td>" ## [124] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 995,872 user ratings\">8.2</strong>\n </td>" ## [125] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 728,829 user ratings\">8.2</strong>\n </td>" ## [126] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 622,555 user ratings\">8.2</strong>\n </td>" ## [127] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 563,055 user ratings\">8.2</strong>\n </td>" ## [128] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 121,545 user ratings\">8.2</strong>\n </td>" ## [129] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 119,191 user ratings\">8.2</strong>\n </td>" ## [130] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 846,514 user ratings\">8.2</strong>\n </td>" ## [131] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 446,422 user ratings\">8.2</strong>\n </td>" ## [132] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 162,959 user ratings\">8.2</strong>\n </td>" ## [133] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 346,121 user ratings\">8.2</strong>\n </td>" ## [134] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 127,915 user ratings\">8.2</strong>\n </td>" ## [135] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 525,254 user ratings\">8.2</strong>\n </td>" ## [136] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 258,643 user ratings\">8.2</strong>\n </td>" ## [137] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 1,387,187 user ratings\">8.2</strong>\n </td>" ## [138] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 398,401 user ratings\">8.2</strong>\n </td>" ## [139] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 71,970 user ratings\">8.2</strong>\n </td>" ## [140] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 170,266 user ratings\">8.2</strong>\n </td>" ## [141] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 368,982 user ratings\">8.2</strong>\n </td>" ## [142] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 1,306,036 user ratings\">8.2</strong>\n </td>" ## [143] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 74,989 user ratings\">8.2</strong>\n </td>" ## [144] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 557,919 user ratings\">8.2</strong>\n </td>" ## [145] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 237,665 user ratings\">8.2</strong>\n </td>" ## [146] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 497,705 user ratings\">8.2</strong>\n </td>" ## [147] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.2 based on 121,571 user ratings\">8.2</strong>\n </td>" ## [148] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 647,987 user ratings\">8.1</strong>\n </td>" ## [149] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 896,776 user ratings\">8.1</strong>\n </td>" ## [150] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 203,930 user ratings\">8.1</strong>\n </td>" ## [151] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 341,110 user ratings\">8.1</strong>\n </td>" ## [152] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 314,754 user ratings\">8.1</strong>\n </td>" ## [153] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 319,764 user ratings\">8.1</strong>\n </td>" ## [154] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 1,229,831 user ratings\">8.1</strong>\n </td>" ## [155] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 564,096 user ratings\">8.1</strong>\n </td>" ## [156] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 923,113 user ratings\">8.1</strong>\n </td>" ## [157] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 136,932 user ratings\">8.1</strong>\n </td>" ## [158] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 169,820 user ratings\">8.1</strong>\n </td>" ## [159] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 108,168 user ratings\">8.1</strong>\n </td>" ## [160] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 402,183 user ratings\">8.1</strong>\n </td>" ## [161] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 479,400 user ratings\">8.1</strong>\n </td>" ## [162] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 26,968 user ratings\">8.1</strong>\n </td>" ## [163] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 178,832 user ratings\">8.1</strong>\n </td>" ## [164] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 233,936 user ratings\">8.1</strong>\n </td>" ## [165] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 956,122 user ratings\">8.1</strong>\n </td>" ## [166] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 1,013,743 user ratings\">8.1</strong>\n </td>" ## [167] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 928,473 user ratings\">8.1</strong>\n </td>" ## [168] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 104,051 user ratings\">8.1</strong>\n </td>" ## [169] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 167,615 user ratings\">8.1</strong>\n </td>" ## [170] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 166,412 user ratings\">8.1</strong>\n </td>" ## [171] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 1,084,856 user ratings\">8.1</strong>\n </td>" ## [172] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 737,437 user ratings\">8.1</strong>\n </td>" ## [173] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 665,554 user ratings\">8.1</strong>\n </td>" ## [174] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 654,580 user ratings\">8.1</strong>\n </td>" ## [175] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 214,418 user ratings\">8.1</strong>\n </td>" ## [176] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 671,630 user ratings\">8.1</strong>\n </td>" ## [177] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 1,001,551 user ratings\">8.1</strong>\n </td>" ## [178] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 1,066,850 user ratings\">8.1</strong>\n </td>" ## [179] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 456,604 user ratings\">8.1</strong>\n </td>" ## [180] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 305,980 user ratings\">8.1</strong>\n </td>" ## [181] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 59,131 user ratings\">8.1</strong>\n </td>" ## [182] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 150,695 user ratings\">8.1</strong>\n </td>" ## [183] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 84,450 user ratings\">8.1</strong>\n </td>" ## [184] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 190,480 user ratings\">8.1</strong>\n </td>" ## [185] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 659,583 user ratings\">8.1</strong>\n </td>" ## [186] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 129,292 user ratings\">8.1</strong>\n </td>" ## [187] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 765,477 user ratings\">8.1</strong>\n </td>" ## [188] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 329,409 user ratings\">8.1</strong>\n </td>" ## [189] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 47,308 user ratings\">8.1</strong>\n </td>" ## [190] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 88,400 user ratings\">8.1</strong>\n </td>" ## [191] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 752,740 user ratings\">8.1</strong>\n </td>" ## [192] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 113,323 user ratings\">8.1</strong>\n </td>" ## [193] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 293,003 user ratings\">8.1</strong>\n </td>" ## [194] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 172,961 user ratings\">8.1</strong>\n </td>" ## [195] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 915,229 user ratings\">8.1</strong>\n </td>" ## [196] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 458,099 user ratings\">8.1</strong>\n </td>" ## [197] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 113,047 user ratings\">8.1</strong>\n </td>" ## [198] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 161,449 user ratings\">8.1</strong>\n </td>" ## [199] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 27,237 user ratings\">8.1</strong>\n </td>" ## [200] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 168,789 user ratings\">8.1</strong>\n </td>" ## [201] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 485,826 user ratings\">8.1</strong>\n </td>" ## [202] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 931,890 user ratings\">8.1</strong>\n </td>" ## [203] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 401,307 user ratings\">8.1</strong>\n </td>" ## [204] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 52,536 user ratings\">8.1</strong>\n </td>" ## [205] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 86,658 user ratings\">8.1</strong>\n </td>" ## [206] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 352,169 user ratings\">8.1</strong>\n </td>" ## [207] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 675,770 user ratings\">8.1</strong>\n </td>" ## [208] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 35,030 user ratings\">8.1</strong>\n </td>" ## [209] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 779,517 user ratings\">8.1</strong>\n </td>" ## [210] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 461,065 user ratings\">8.1</strong>\n </td>" ## [211] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 827,499 user ratings\">8.1</strong>\n </td>" ## [212] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 232,048 user ratings\">8.1</strong>\n </td>" ## [213] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 706,987 user ratings\">8.1</strong>\n </td>" ## [214] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 949,615 user ratings\">8.1</strong>\n </td>" ## [215] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 32,801 user ratings\">8.1</strong>\n </td>" ## [216] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 666,918 user ratings\">8.1</strong>\n </td>" ## [217] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 59,185 user ratings\">8.1</strong>\n </td>" ## [218] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 386,516 user ratings\">8.1</strong>\n </td>" ## [219] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 133,575 user ratings\">8.1</strong>\n </td>" ## [220] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 154,555 user ratings\">8.1</strong>\n </td>" ## [221] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 709,327 user ratings\">8.1</strong>\n </td>" ## [222] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.1 based on 164,354 user ratings\">8.1</strong>\n </td>" ## [223] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 69,898 user ratings\">8.0</strong>\n </td>" ## [224] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 172,452 user ratings\">8.0</strong>\n </td>" ## [225] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 272,353 user ratings\">8.0</strong>\n </td>" ## [226] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 92,115 user ratings\">8.0</strong>\n </td>" ## [227] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 113,645 user ratings\">8.0</strong>\n </td>" ## [228] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 401,189 user ratings\">8.0</strong>\n </td>" ## [229] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 451,856 user ratings\">8.0</strong>\n </td>" ## [230] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 867,959 user ratings\">8.0</strong>\n </td>" ## [231] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 133,188 user ratings\">8.0</strong>\n </td>" ## [232] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 387,727 user ratings\">8.0</strong>\n </td>" ## [233] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 141,435 user ratings\">8.0</strong>\n </td>" ## [234] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 347,572 user ratings\">8.0</strong>\n </td>" ## [235] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 68,886 user ratings\">8.0</strong>\n </td>" ## [236] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 461,379 user ratings\">8.0</strong>\n </td>" ## [237] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 550,599 user ratings\">8.0</strong>\n </td>" ## [238] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 234,975 user ratings\">8.0</strong>\n </td>" ## [239] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 604,187 user ratings\">8.0</strong>\n </td>" ## [240] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 163,587 user ratings\">8.0</strong>\n </td>" ## [241] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 100,609 user ratings\">8.0</strong>\n </td>" ## [242] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 252,785 user ratings\">8.0</strong>\n </td>" ## [243] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 62,391 user ratings\">8.0</strong>\n </td>" ## [244] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 44,604 user ratings\">8.0</strong>\n </td>" ## [245] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 58,041 user ratings\">8.0</strong>\n </td>" ## [246] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 47,356 user ratings\">8.0</strong>\n </td>" ## [247] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 39,258 user ratings\">8.0</strong>\n </td>" ## [248] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 52,044 user ratings\">8.0</strong>\n </td>" ## [249] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 50,007 user ratings\">8.0</strong>\n </td>" ## [250] "<td class=\"ratingColumn imdbRating\">\n <strong title=\"8.0 based on 416,514 user ratings\">8.0</strong>\n </td>" ``` ] --- # ¿Cómo obtenemos la popularidad (número de usuarios)? .scrollable[ ```r html_elements(datos, ".imdbRating") %>% as.character() %>% * gsub(pattern = ".*based on | user.*", replacement = "") ``` ``` ## [1] "2,531,700" "1,742,891" "1,209,198" "2,482,152" "748,065" ## [6] "1,293,509" "1,747,018" "1,949,998" "731,614" "1,768,396" ## [11] "1,991,339" "1,953,976" "2,224,763" "1,578,445" "1,229,090" ## [16] "1,826,876" "1,095,102" "969,761" "334,541" "1,553,428" ## [21] "412,230" "1,361,143" "732,467" "438,390" "665,547" ## [26] "1,321,592" "1,300,609" "1,677,437" "714,107" "1,231,748" ## [31] "709,314" "1,106,314" "51,721" "789,182" "1,052,376" ## [36] "1,138,876" "1,046,304" "643,322" "1,005,098" "233,246" ## [41] "259,944" "1,082,985" "786,708" "1,429,325" "179,056" ## [46] "1,265,213" "815,790" "1,271,569" "551,891" "319,396" ## [51] "473,904" "250,455" "840,139" "641,438" "1,189,688" ## [56] "931,623" "216,945" "1,463,753" "378,535" "190,431" ## [61] "214,640" "1,064,290" "972,106" "119,706" "464,284" ## [66] "966,871" "474,230" "373,966" "552,568" "1,132,183" ## [71] "238,093" "456,615" "1,610,958" "690,362" "336,927" ## [76] "1,000,782" "80,736" "244,173" "41,343" "376,773" ## [81] "946,338" "388,247" "1,119,463" "1,003,644" "1,365,916" ## [86] "920,815" "81,385" "1,004,735" "71,458" "641,827" ## [91] "975,499" "184,733" "389,148" "153,172" "312,416" ## [96] "428,996" "808,322" "233,320" "317,597" "965,057" ## [101] "75,365" "158,432" "284,236" "122,576" "713,333" ## [106] "167,993" "177,104" "175,448" "152,262" "169,424" ## [111] "120,085" "236,017" "779,371" "798,908" "254,194" ## [116] "795,535" "825,488" "526,049" "734,458" "308,205" ## [121] "800,434" "247,853" "30,222" "995,872" "728,829" ## [126] "622,555" "563,055" "121,545" "119,191" "846,514" ## [131] "446,422" "162,959" "346,121" "127,915" "525,254" ## [136] "258,643" "1,387,187" "398,401" "71,970" "170,266" ## [141] "368,982" "1,306,036" "74,989" "557,919" "237,665" ## [146] "497,705" "121,571" "647,987" "896,776" "203,930" ## [151] "341,110" "314,754" "319,764" "1,229,831" "564,096" ## [156] "923,113" "136,932" "169,820" "108,168" "402,183" ## [161] "479,400" "26,968" "178,832" "233,936" "956,122" ## [166] "1,013,743" "928,473" "104,051" "167,615" "166,412" ## [171] "1,084,856" "737,437" "665,554" "654,580" "214,418" ## [176] "671,630" "1,001,551" "1,066,850" "456,604" "305,980" ## [181] "59,131" "150,695" "84,450" "190,480" "659,583" ## [186] "129,292" "765,477" "329,409" "47,308" "88,400" ## [191] "752,740" "113,323" "293,003" "172,961" "915,229" ## [196] "458,099" "113,047" "161,449" "27,237" "168,789" ## [201] "485,826" "931,890" "401,307" "52,536" "86,658" ## [206] "352,169" "675,770" "35,030" "779,517" "461,065" ## [211] "827,499" "232,048" "706,987" "949,615" "32,801" ## [216] "666,918" "59,185" "386,516" "133,575" "154,555" ## [221] "709,327" "164,354" "69,898" "172,452" "272,353" ## [226] "92,115" "113,645" "401,189" "451,856" "867,959" ## [231] "133,188" "387,727" "141,435" "347,572" "68,886" ## [236] "461,379" "550,599" "234,975" "604,187" "163,587" ## [241] "100,609" "252,785" "62,391" "44,604" "58,041" ## [246] "47,356" "39,258" "52,044" "50,007" "416,514" ``` ] --- # ¿Cómo obtenemos la popularidad (número de usuarios)? .scrollable[ ```r html_elements(datos, ".imdbRating") %>% as.character() %>% gsub(pattern = ".*based on | user.*", replacement = "") %>% * gsub(pattern = "\\,", replacement = "") ``` ``` ## [1] "2531700" "1742891" "1209198" "2482152" "748065" "1293509" ## [7] "1747018" "1949998" "731614" "1768396" "1991339" "1953976" ## [13] "2224763" "1578445" "1229090" "1826876" "1095102" "969761" ## [19] "334541" "1553428" "412230" "1361143" "732467" "438390" ## [25] "665547" "1321592" "1300609" "1677437" "714107" "1231748" ## [31] "709314" "1106314" "51721" "789182" "1052376" "1138876" ## [37] "1046304" "643322" "1005098" "233246" "259944" "1082985" ## [43] "786708" "1429325" "179056" "1265213" "815790" "1271569" ## [49] "551891" "319396" "473904" "250455" "840139" "641438" ## [55] "1189688" "931623" "216945" "1463753" "378535" "190431" ## [61] "214640" "1064290" "972106" "119706" "464284" "966871" ## [67] "474230" "373966" "552568" "1132183" "238093" "456615" ## [73] "1610958" "690362" "336927" "1000782" "80736" "244173" ## [79] "41343" "376773" "946338" "388247" "1119463" "1003644" ## [85] "1365916" "920815" "81385" "1004735" "71458" "641827" ## [91] "975499" "184733" "389148" "153172" "312416" "428996" ## [97] "808322" "233320" "317597" "965057" "75365" "158432" ## [103] "284236" "122576" "713333" "167993" "177104" "175448" ## [109] "152262" "169424" "120085" "236017" "779371" "798908" ## [115] "254194" "795535" "825488" "526049" "734458" "308205" ## [121] "800434" "247853" "30222" "995872" "728829" "622555" ## [127] "563055" "121545" "119191" "846514" "446422" "162959" ## [133] "346121" "127915" "525254" "258643" "1387187" "398401" ## [139] "71970" "170266" "368982" "1306036" "74989" "557919" ## [145] "237665" "497705" "121571" "647987" "896776" "203930" ## [151] "341110" "314754" "319764" "1229831" "564096" "923113" ## [157] "136932" "169820" "108168" "402183" "479400" "26968" ## [163] "178832" "233936" "956122" "1013743" "928473" "104051" ## [169] "167615" "166412" "1084856" "737437" "665554" "654580" ## [175] "214418" "671630" "1001551" "1066850" "456604" "305980" ## [181] "59131" "150695" "84450" "190480" "659583" "129292" ## [187] "765477" "329409" "47308" "88400" "752740" "113323" ## [193] "293003" "172961" "915229" "458099" "113047" "161449" ## [199] "27237" "168789" "485826" "931890" "401307" "52536" ## [205] "86658" "352169" "675770" "35030" "779517" "461065" ## [211] "827499" "232048" "706987" "949615" "32801" "666918" ## [217] "59185" "386516" "133575" "154555" "709327" "164354" ## [223] "69898" "172452" "272353" "92115" "113645" "401189" ## [229] "451856" "867959" "133188" "387727" "141435" "347572" ## [235] "68886" "461379" "550599" "234975" "604187" "163587" ## [241] "100609" "252785" "62391" "44604" "58041" "47356" ## [247] "39258" "52044" "50007" "416514" ``` ] --- # ¿Cómo obtenemos la popularidad (número de usuarios)? .scrollable[ ```r n.users <- html_elements(datos, ".imdbRating") %>% as.character() %>% gsub(pattern = ".*based on | user.*", replacement = "") %>% gsub(pattern = "\\,", replacement = "") %>% * as.numeric() *n.users ``` ``` ## [1] 2531700 1742891 1209198 2482152 748065 1293509 1747018 ## [8] 1949998 731614 1768396 1991339 1953976 2224763 1578445 ## [15] 1229090 1826876 1095102 969761 334541 1553428 412230 ## [22] 1361143 732467 438390 665547 1321592 1300609 1677437 ## [29] 714107 1231748 709314 1106314 51721 789182 1052376 ## [36] 1138876 1046304 643322 1005098 233246 259944 1082985 ## [43] 786708 1429325 179056 1265213 815790 1271569 551891 ## [50] 319396 473904 250455 840139 641438 1189688 931623 ## [57] 216945 1463753 378535 190431 214640 1064290 972106 ## [64] 119706 464284 966871 474230 373966 552568 1132183 ## [71] 238093 456615 1610958 690362 336927 1000782 80736 ## [78] 244173 41343 376773 946338 388247 1119463 1003644 ## [85] 1365916 920815 81385 1004735 71458 641827 975499 ## [92] 184733 389148 153172 312416 428996 808322 233320 ## [99] 317597 965057 75365 158432 284236 122576 713333 ## [106] 167993 177104 175448 152262 169424 120085 236017 ## [113] 779371 798908 254194 795535 825488 526049 734458 ## [120] 308205 800434 247853 30222 995872 728829 622555 ## [127] 563055 121545 119191 846514 446422 162959 346121 ## [134] 127915 525254 258643 1387187 398401 71970 170266 ## [141] 368982 1306036 74989 557919 237665 497705 121571 ## [148] 647987 896776 203930 341110 314754 319764 1229831 ## [155] 564096 923113 136932 169820 108168 402183 479400 ## [162] 26968 178832 233936 956122 1013743 928473 104051 ## [169] 167615 166412 1084856 737437 665554 654580 214418 ## [176] 671630 1001551 1066850 456604 305980 59131 150695 ## [183] 84450 190480 659583 129292 765477 329409 47308 ## [190] 88400 752740 113323 293003 172961 915229 458099 ## [197] 113047 161449 27237 168789 485826 931890 401307 ## [204] 52536 86658 352169 675770 35030 779517 461065 ## [211] 827499 232048 706987 949615 32801 666918 59185 ## [218] 386516 133575 154555 709327 164354 69898 172452 ## [225] 272353 92115 113645 401189 451856 867959 133188 ## [232] 387727 141435 347572 68886 461379 550599 234975 ## [239] 604187 163587 100609 252785 62391 44604 58041 ## [246] 47356 39258 52044 50007 416514 ``` ] --- class: center, middle background-color: rosybrown # ¿Cómo creamos una base de datos de R con toda la información recogida? --- # ¿Cómo creamos una base de datos de R con toda la información recogida? .scrollable[ ```r imdb <- data.frame(Pelicula = movies, Fecha = year, Nota = rates, Popularidad = n.users) str(imdb) ``` ``` ## 'data.frame': 250 obs. of 4 variables: ## $ Pelicula : chr "Cadena perpetua" "El padrino" "El padrino: Parte II" "El caballero oscuro" ... ## $ Fecha : num 1994 1972 1974 2008 1957 ... ## $ Nota : num 9.2 9.1 9 9 8.9 8.9 8.9 8.8 8.8 8.8 ... ## $ Popularidad: num 2531700 1742891 1209198 2482152 748065 ... ``` ```r head(imdb) ``` ``` ## Pelicula Fecha Nota Popularidad ## 1 Cadena perpetua 1994 9.2 2531700 ## 2 El padrino 1972 9.1 1742891 ## 3 El padrino: Parte II 1974 9.0 1209198 ## 4 El caballero oscuro 2008 9.0 2482152 ## 5 12 hombres sin piedad 1957 8.9 748065 ## 6 La lista de Schindler 1993 8.9 1293509 ``` ] --- class: center, middle background-color: rosybrown # ¿Qué título consta de más palabras? --- # ¿Qué título consta de más palabras? .scrollable[ ```r strsplit(imdb$Pelicula, " ") ``` ``` ## [[1]] ## [1] "Cadena" "perpetua" ## ## [[2]] ## [1] "El" "padrino" ## ## [[3]] ## [1] "El" "padrino:" "Parte" "II" ## ## [[4]] ## [1] "El" "caballero" "oscuro" ## ## [[5]] ## [1] "12" "hombres" "sin" "piedad" ## ## [[6]] ## [1] "La" "lista" "de" "Schindler" ## ## [[7]] ## [1] "El" "señor" "de" "los" "anillos:" ## [6] "El" "retorno" "del" "rey" ## ## [[8]] ## [1] "Pulp" "Fiction" ## ## [[9]] ## [1] "El" "bueno," "el" "feo" "y" "el" ## [7] "malo" ## ## [[10]] ## [1] "El" "señor" "de" "los" "anillos:" ## [6] "La" "comunidad" "del" "anillo" ## ## [[11]] ## [1] "El" "club" "de" "la" "lucha" ## ## [[12]] ## [1] "Forrest" "Gump" ## ## [[13]] ## [1] "Origen" ## ## [[14]] ## [1] "El" "señor" "de" "los" "anillos:" ## [6] "Las" "dos" "torres" ## ## [[15]] ## [1] "El" "Imperio" "contraataca" ## ## [[16]] ## [1] "Matrix" ## ## [[17]] ## [1] "Uno" "de" "los" "nuestros" ## ## [[18]] ## [1] "Alguien" "voló" "sobre" "el" "nido" "del" ## [7] "cuco" ## ## [[19]] ## [1] "Los" "siete" "samuráis" ## ## [[20]] ## [1] "Seven" ## ## [[21]] ## [1] "Spider-Man:" "No" "Way" "Home" ## ## [[22]] ## [1] "El" "silencio" "de" "los" "corderos" ## ## [[23]] ## [1] "Ciudad" "de" "Dios" ## ## [[24]] ## [1] "¡Qué" "bello" "es" "vivir!" ## ## [[25]] ## [1] "La" "vida" "es" "bella" ## ## [[26]] ## [1] "Salvar" "al" "soldado" "Ryan" ## ## [[27]] ## [1] "La" "guerra" "de" "las" "galaxias" ## ## [[28]] ## [1] "Interstellar" ## ## [[29]] ## [1] "El" "viaje" "de" "Chihiro" ## ## [[30]] ## [1] "La" "milla" "verde" ## ## [[31]] ## [1] "Parásitos" ## ## [[32]] ## [1] "El" "profesional" "(Léon)" ## ## [[33]] ## [1] "Harakiri" ## ## [[34]] ## [1] "El" "pianista" ## ## [[35]] ## [1] "Terminator" "2:" "El" "juicio" ## [5] "final" ## ## [[36]] ## [1] "Regreso" "al" "futuro" ## ## [[37]] ## [1] "Sospechosos" "habituales" ## ## [[38]] ## [1] "Psicosis" ## ## [[39]] ## [1] "El" "rey" "león" ## ## [[40]] ## [1] "Tiempos" "modernos" ## ## [[41]] ## [1] "La" "tumba" "de" "las" ## [5] "luciérnagas" ## ## [[42]] ## [1] "American" "History" "X" ## ## [[43]] ## [1] "Whiplash" ## ## [[44]] ## [1] "Gladiator" "(El" "gladiador)" ## ## [[45]] ## [1] "Luces" "de" "la" "ciudad" ## ## [[46]] ## [1] "Infiltrados" ## ## [[47]] ## [1] "Intocable" ## ## [[48]] ## [1] "El" "truco" "final" "(El" ## [5] "prestigio)" ## ## [[49]] ## [1] "Casablanca" ## ## [[50]] ## [1] "Hasta" "que" "llegó" "su" "hora" ## ## [[51]] ## [1] "La" "ventana" "indiscreta" ## ## [[52]] ## [1] "Cinema" "Paradiso" ## ## [[53]] ## [1] "Alien," "el" "octavo" "pasajero" ## ## [[54]] ## [1] "Apocalypse" "Now" ## ## [[55]] ## [1] "Memento" ## ## [[56]] ## [1] "En" "busca" "del" "arca" "perdida" ## ## [[57]] ## [1] "El" "gran" "dictador" ## ## [[58]] ## [1] "Django" "desencadenado" ## ## [[59]] ## [1] "La" "vida" "de" "los" "otros" ## ## [[60]] ## [1] "Senderos" "de" "gloria" ## ## [[61]] ## [1] "El" "crepúsculo" "de" "los" ## [5] "dioses" ## ## [[62]] ## [1] "WALL·E" ## ## [[63]] ## [1] "Vengadores:" "Infinity" "War" ## ## [[64]] ## [1] "Testigo" "de" "cargo" ## ## [[65]] ## [1] "Spider-Man:" "Un" "nuevo" "universo" ## ## [[66]] ## [1] "El" "resplandor" ## ## [[67]] ## [1] "¿Teléfono" "rojo?" "Volamos" "hacia" "Moscú" ## ## [[68]] ## [1] "La" "princesa" "Mononoke" ## ## [[69]] ## [1] "Old" "Boy" ## ## [[70]] ## [1] "Joker" ## ## [[71]] ## [1] "Your" "Name." ## ## [[72]] ## [1] "Coco" ## ## [[73]] ## [1] "El" "caballero" "oscuro:" "La" "leyenda" ## [6] "renace" ## ## [[74]] ## [1] "Aliens:" "El" "regreso" ## ## [[75]] ## [1] "Érase" "una" "vez" "en" "América" ## ## [[76]] ## [1] "Vengadores:" "Endgame" ## ## [[77]] ## [1] "Cafarnaúm" ## ## [[78]] ## [1] "El" "submarino" "(Das" "Boot)" ## ## [[79]] ## [1] "El" "infierno" "del" "odio" ## ## [[80]] ## [1] "3" "Idiots" ## ## [[81]] ## [1] "Toy" "Story" ## ## [[82]] ## [1] "Amadeus" ## ## [[83]] ## [1] "American" "Beauty" ## ## [[84]] ## [1] "Braveheart" ## ## [[85]] ## [1] "Malditos" "bastardos" ## ## [[86]] ## [1] "El" "indomable" "Will" "Hunting" ## ## [[87]] ## [1] "Hamilton" ## ## [[88]] ## [1] "El" "retorno" "del" "jedi" ## ## [[89]] ## [1] "Masacre" "(Ven" "y" "mira)" ## ## [[90]] ## [1] "2001:" "Una" "odisea" "del" "espacio" ## ## [[91]] ## [1] "Reservoir" "Dogs" ## ## [[92]] ## [1] "Taare" "Zameen" "Par" ## ## [[93]] ## [1] "Vértigo" "(De" "entre" "los" "muertos)" ## ## [[94]] ## [1] "M," "el" "vampiro" "de" ## [5] "Düsseldorf" ## ## [[95]] ## [1] "La" "caza" ## ## [[96]] ## [1] "Ciudadano" "Kane" ## ## [[97]] ## [1] "Réquiem" "por" "un" "sueño" ## ## [[98]] ## [1] "Cantando" "bajo" "la" "lluvia" ## ## [[99]] ## [1] "Con" "la" "muerte" "en" "los" "talones" ## ## [[100]] ## [1] "¡Olvídate" "de" "mí!" ## ## [[101]] ## [1] "Ikiru" "(Vivir)" ## ## [[102]] ## [1] "Ladrón" "de" "bicicletas" ## ## [[103]] ## [1] "Lawrence" "de" "Arabia" ## ## [[104]] ## [1] "El" "chico" ## ## [[105]] ## [1] "La" "chaqueta" "metálica" ## ## [[106]] ## [1] "Incendios" ## ## [[107]] ## [1] "Dangal" ## ## [[108]] ## [1] "El" "apartamento" ## ## [[109]] ## [1] "Perdición" ## ## [[110]] ## [1] "Metrópolis" ## ## [[111]] ## [1] "El" "padre" ## ## [[112]] ## [1] "Nader" "y" "Simin," "una" ## [5] "separación" ## ## [[113]] ## [1] "Taxi" "Driver" ## ## [[114]] ## [1] "La" "naranja" "mecánica" ## ## [[115]] ## [1] "El" "golpe" ## ## [[116]] ## [1] "El" "precio" "del" "poder" ## ## [[117]] ## [1] "Snatch," "cerdos" "y" "diamantes" ## ## [[118]] ## [1] "1917" ## ## [[119]] ## [1] "Amelie" ## ## [[120]] ## [1] "Matar" "a" "un" "ruiseñor" ## ## [[121]] ## [1] "Toy" "Story" "3" ## ## [[122]] ## [1] "La" "muerte" "tenía" "un" "precio" ## ## [[123]] ## [1] "Pather" "Panchali" "(La" "canción" "del" ## [6] "camino)" ## ## [[124]] ## [1] "Up" ## ## [[125]] ## [1] "Indiana" "Jones" "y" "la" "última" "cruzada" ## ## [[126]] ## [1] "Heat" ## ## [[127]] ## [1] "L.A." "Confidential" ## ## [[128]] ## [1] "Ran" ## ## [[129]] ## [1] "Yojimbo" ## ## [[130]] ## [1] "Jungla" "de" "cristal" ## ## [[131]] ## [1] "Green" "Book" ## ## [[132]] ## [1] "Rashomon" ## ## [[133]] ## [1] "El" "hundimiento" ## ## [[134]] ## [1] "Eva" "al" "desnudo" ## ## [[135]] ## [1] "Los" "caballeros" "de" "la" ## [5] "mesa" "cuadrada" "y" "sus" ## [9] "locos" "seguidores" ## ## [[136]] ## [1] "Con" "faldas" "y" "a" "lo" "loco" ## ## [[137]] ## [1] "Batman" "Begins" ## ## [[138]] ## [1] "Sin" "perdón" ## ## [[139]] ## [1] "Children" "of" "Heaven" ## ## [[140]] ## [1] "Jai" "Bhim" ## ## [[141]] ## [1] "El" "castillo" "ambulante" ## ## [[142]] ## [1] "El" "lobo" "de" "Wall" "Street" ## ## [[143]] ## [1] "Vencedores" "o" "vencidos" ## ## [[144]] ## [1] "Pozos" "de" "ambición" ## ## [[145]] ## [1] "La" "gran" "evasión" ## ## [[146]] ## [1] "Casino" ## ## [[147]] ## [1] "El" "tesoro" "de" "Sierra" "Madre" ## ## [[148]] ## [1] "El" "laberinto" "del" "fauno" ## ## [[149]] ## [1] "Una" "mente" "maravillosa" ## ## [[150]] ## [1] "El" "secreto" "de" "sus" "ojos" ## ## [[151]] ## [1] "Toro" "salvaje" ## ## [[152]] ## [1] "Chinatown" ## ## [[153]] ## [1] "Mi" "vecino" "Totoro" ## ## [[154]] ## [1] "Shutter" "Island" ## ## [[155]] ## [1] "Lock" "&" "Stock" ## ## [[156]] ## [1] "No" "es" "país" "para" "viejos" ## ## [[157]] ## [1] "Klaus" ## ## [[158]] ## [1] "Crimen" "perfecto" ## ## [[159]] ## [1] "La" "quimera" "del" "oro" ## ## [[160]] ## [1] "La" "cosa" ## ## [[161]] ## [1] "Tres" "anuncios" "en" "las" "afueras" ## ## [[162]] ## [1] "Dersu" "Uzala" "(El" "cazador)" ## ## [[163]] ## [1] "El" "séptimo" "sello" ## ## [[164]] ## [1] "El" "hombre" "elefante" ## ## [[165]] ## [1] "El" "sexto" "sentido" ## ## [[166]] ## [1] "El" "show" "de" "Truman" ## ## [[167]] ## [1] "Jurassic" "Park" "(Parque" "Jurásico)" ## ## [[168]] ## [1] "Fresas" "salvajes" ## ## [[169]] ## [1] "El" "tercer" "hombre" ## ## [[170]] ## [1] "Memories" "of" "Murder" "(Crónica" "de" ## [6] "un" "asesino" "en" "serie)" ## ## [[171]] ## [1] "V" "de" "Vendetta" ## ## [[172]] ## [1] "Blade" "Runner" ## ## [[173]] ## [1] "Trainspotting" ## ## [[174]] ## [1] "Fargo" ## ## [[175]] ## [1] "El" "puente" "sobre" "el" "río" "Kwai" ## ## [[176]] ## [1] "Del" "revés" "(Inside" "Out)" ## ## [[177]] ## [1] "Buscando" "a" "Nemo" ## ## [[178]] ## [1] "Kill" "Bill:" "Volumen" "1" ## ## [[179]] ## [1] "Warrior" ## ## [[180]] ## [1] "Lo" "que" "el" "viento" "se" "llevó" ## ## [[181]] ## [1] "Cuentos" "de" "Tokio" ## ## [[182]] ## [1] "La" "ley" "del" "silencio" ## ## [[183]] ## [1] "Mi" "padre" "y" "mi" "hijo" ## ## [[184]] ## [1] "Relatos" "salvajes" ## ## [[185]] ## [1] "Prisioneros" ## ## [[186]] ## [1] "Stalker" ## ## [[187]] ## [1] "El" "gran" "hotel" "Budapest" ## ## [[188]] ## [1] "El" "cazador" ## ## [[189]] ## [1] "El" "moderno" "Sherlock" "Holmes" ## ## [[190]] ## [1] "El" "maquinista" "de" "La" ## [5] "General" ## ## [[191]] ## [1] "Gran" "Torino" ## ## [[192]] ## [1] "Persona" ## ## [[193]] ## [1] "Antes" "de" "amanecer" ## ## [[194]] ## [1] "Mary" "and" "Max" ## ## [[195]] ## [1] "Atrápame" "si" "puedes" ## ## [[196]] ## [1] "Dune" ## ## [[197]] ## [1] "Caballero" "sin" "espada" ## ## [[198]] ## [1] "Barry" "Lyndon" ## ## [[199]] ## [1] "Z" ## ## [[200]] ## [1] "En" "el" "nombre" "del" "padre" ## ## [[201]] ## [1] "Hasta" "el" "último" "hombre" ## ## [[202]] ## [1] "Perdida" ## ## [[203]] ## [1] "La" "habitación" ## ## [[204]] ## [1] "La" "pasión" "de" "Juana" "de" "Arco" ## ## [[205]] ## [1] "Andhadhun" ## ## [[206]] ## [1] "Le" "Mans" "'66" ## ## [[207]] ## [1] "12" "años" "de" "esclavitud" ## ## [[208]] ## [1] "Ser" "o" "no" "ser" ## ## [[209]] ## [1] "El" "gran" "Lebowski" ## ## [[210]] ## [1] "El" "club" "de" "los" "poetas" "muertos" ## ## [[211]] ## [1] "Harry" "Potter" "y" "las" "Reliquias" ## [6] "de" "la" "Muerte" "-" "Parte" ## [11] "2" ## ## [[212]] ## [1] "Ben-Hur" ## ## [[213]] ## [1] "Cómo" "entrenar" "a" "tu" "dragón" ## ## [[214]] ## [1] "Mad" "Max:" "Furia" "en" "la" ## [6] "carretera" ## ## [[215]] ## [1] "Sonata" "de" "otoño" ## ## [[216]] ## [1] "Million" "Dollar" "Baby" ## ## [[217]] ## [1] "El" "salario" "del" "miedo" ## ## [[218]] ## [1] "Cuenta" "conmigo" ## ## [[219]] ## [1] "La" "doncella" ## ## [[220]] ## [1] "Network," "un" "mundo" "implacable" ## ## [[221]] ## [1] "Logan" ## ## [[222]] ## [1] "El" "odio" ## ## [[223]] ## [1] "A" "Silent" "Voice" ## ## [[224]] ## [1] "La" "leyenda" "del" "indomable" ## ## [[225]] ## [1] "Siempre" "a" "tu" "lado" "(Hachiko)" ## ## [[226]] ## [1] "Gangs" "of" "Wasseypur" ## ## [[227]] ## [1] "Los" "cuatrocientos" "golpes" ## ## [[228]] ## [1] "Platoon" ## ## [[229]] ## [1] "Spotlight" ## ## [[230]] ## [1] "Monstruos," "S.A." ## ## [[231]] ## [1] "Rebeca" ## ## [[232]] ## [1] "La" "vida" "de" "Brian" ## ## [[233]] ## [1] "Deseando" "amar" ## ## [[234]] ## [1] "Hotel" "Rwanda" ## ## [[235]] ## [1] "Eskiya" ## ## [[236]] ## [1] "Rush" ## ## [[237]] ## [1] "Rocky" ## ## [[238]] ## [1] "Amores" "perros" ## ## [[239]] ## [1] "Hacia" "rutas" "salvajes" ## ## [[240]] ## [1] "Nausicaä" "del" "Valle" "del" "Viento" ## ## [[241]] ## [1] "Sucedió" "una" "noche" ## ## [[242]] ## [1] "Antes" "del" "atardecer" ## ## [[243]] ## [1] "Fanny" "y" "Alexander" ## ## [[244]] ## [1] "Guardianes" "de" "la" "noche" ## [5] "-" "Kimetsu" "no" "Yaiba" ## [9] "-" "La" "película:" "Tren" ## [13] "Infinito" ## ## [[245]] ## [1] "La" "batalla" "de" "Argel" ## ## [[246]] ## [1] "Las" "noches" "de" "Cabiria" ## ## [[247]] ## [1] "Drishyam" ## ## [[248]] ## [1] "Andrei" "Rublev" ## ## [[249]] ## [1] "Neon" "Genesis" "Evangelion:" "The" ## [5] "End" "of" "Evangelion" ## ## [[250]] ## [1] "La" "princesa" "prometida" ``` ] --- # ¿Qué título consta de más palabras? .scrollable[ ```r strsplit(imdb$Pelicula, " ") %>% * sapply(length) ``` ``` ## [1] 2 2 4 3 4 4 9 2 7 9 5 2 1 8 3 1 4 7 3 1 ## [21] 4 5 3 4 4 4 5 1 4 3 1 3 1 2 5 3 2 1 3 2 ## [41] 5 3 1 3 4 1 1 5 1 5 3 2 4 2 1 5 3 2 5 3 ## [61] 5 1 3 3 4 2 5 3 2 1 2 1 6 3 5 2 1 4 4 2 ## [81] 2 1 2 1 2 4 1 4 4 5 2 3 5 5 2 2 4 4 6 3 ## [101] 2 3 3 2 3 1 1 2 1 1 2 5 2 3 2 4 4 1 1 4 ## [121] 3 5 6 1 6 1 2 1 1 3 2 1 2 3 10 6 2 2 3 2 ## [141] 3 5 3 3 3 1 5 4 3 5 2 1 3 2 3 5 1 2 4 2 ## [161] 5 4 3 3 3 4 4 2 3 9 3 2 1 1 6 4 3 4 1 6 ## [181] 3 4 5 2 1 1 4 2 4 5 2 1 3 3 3 1 3 2 1 5 ## [201] 4 1 2 6 1 3 4 4 3 6 11 1 5 6 3 3 4 2 2 4 ## [221] 1 2 3 4 5 3 3 1 1 2 1 4 2 2 1 1 1 2 3 5 ## [241] 3 3 3 13 4 4 1 2 7 3 ``` ] --- # ¿Qué título consta de más palabras? .scrollable[ ```r palabras.peli <- strsplit(imdb$Pelicula, " ") %>% sapply(length) *which.max(palabras.peli) ``` ``` ## [1] 244 ``` ] -- <br> .center[.content-box-purple[¿Qué película ocupa la fila 244?]] -- .scrollable[ ```r imdb$Pelicula[which.max(palabras.peli)] ``` ``` ## [1] "Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito" ``` ] --- class: center, middle background-color: rosybrown # ¿Qué título es el más largo? Contando todos los caracteres (espacios, guiones, etc.) --- # ¿Qué título es el más largo? Contando todos los caracteres (espacios, guiones, etc.) .scrollable[ ```r caracteres.peli <- nchar(imdb$Pelicula) caracteres.peli ``` ``` ## [1] 15 10 20 19 21 21 43 12 26 48 19 12 6 39 22 6 19 35 18 5 ## [21] 23 27 14 20 16 22 25 12 19 14 9 21 8 11 29 17 22 8 11 16 ## [41] 27 18 8 24 18 11 9 29 10 23 21 15 25 14 7 25 16 20 20 18 ## [61] 27 6 24 16 29 13 35 20 7 5 10 4 38 18 24 19 9 23 20 8 ## [81] 9 7 15 10 18 25 8 19 20 28 14 16 30 27 7 14 20 23 28 16 ## [101] 13 20 18 8 20 9 6 14 9 10 8 29 11 19 8 19 26 4 6 19 ## [121] 11 25 39 2 33 4 17 3 7 17 10 8 14 14 57 22 13 10 18 8 ## [141] 21 22 21 17 15 6 25 22 21 22 12 9 16 14 12 22 5 15 18 7 ## [161] 28 24 16 18 16 17 31 15 16 51 13 12 13 5 27 22 15 20 7 25 ## [181] 16 19 18 16 11 7 22 10 26 27 11 7 17 12 18 4 20 12 1 22 ## [201] 22 7 13 26 9 11 21 12 16 29 51 7 25 30 15 19 20 14 11 28 ## [221] 5 7 14 24 27 18 24 7 9 15 6 16 13 12 6 4 5 13 20 29 ## [241] 17 19 17 70 19 21 8 13 46 21 ``` ] --- # ¿Qué título es el más largo? Contando todos los caracteres (espacios, guiones, etc.) .scrollable[ ```r caracteres.peli <- nchar(imdb$Pelicula) *which.max(caracteres.peli) ``` ``` ## [1] 244 ``` ] -- <br> .center[.content-box-purple[¿Qué película ocupa la fila 244?]] -- .scrollable[ ```r imdb$Pelicula[which.max(caracteres.peli)] ``` ``` ## [1] "Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito" ``` ] --- class: center, middle background-color: rosybrown # ¿Qué títulos tienen números? --- # ¿Qué títulos tienen números? .scrollable[ ```r grep(imdb$Pelicula, pattern = "[[:digit:]]", value = TRUE) ``` ``` ## [1] "12 hombres sin piedad" ## [2] "Terminator 2: El juicio final" ## [3] "3 Idiots" ## [4] "2001: Una odisea del espacio" ## [5] "1917" ## [6] "Toy Story 3" ## [7] "Kill Bill: Volumen 1" ## [8] "Le Mans '66" ## [9] "12 años de esclavitud" ## [10] "Harry Potter y las Reliquias de la Muerte - Parte 2" ``` ] --- class: center, middle background-color: rosybrown # ¿Qué títulos NO empiezan por mayúscula? --- # ¿Qué títulos NO empiezan por mayúscula? Calculamos en primer lugar las filas de las películas cuyos títulos SÍ empiezan por mayúscula. -- .scroll-medium[ ```r grep(imdb$Pelicula, pattern = "^[[:upper:]]") ``` ``` ## [1] 1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 ## [16] 17 18 19 20 21 22 23 25 26 27 28 29 30 31 32 ## [31] 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 ## [46] 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 ## [61] 63 64 65 66 68 69 70 71 72 73 74 75 76 77 78 ## [76] 79 81 82 83 84 85 86 87 88 89 91 92 93 94 95 ## [91] 96 97 98 99 101 102 103 104 105 106 107 108 109 110 111 ## [106] 112 113 114 115 116 117 119 120 121 122 123 124 125 126 127 ## [121] 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 ## [136] 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 ## [151] 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 ## [166] 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 ## [181] 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 ## [196] 203 204 205 206 208 209 210 211 212 213 214 215 216 217 218 ## [211] 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 ## [226] 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 ## [241] 249 250 ``` ] --- # ¿Qué títulos NO empiezan por mayúscula? La pregunta equivale a la siguiente: ## ¿Cómo obtenemos los títulos de las películas excepto las de las filas calculadas anteriormente? -- .scrollable[ ```r imdb$Pelicula[-grep(imdb$Pelicula, pattern = "^[[:upper:]]")] ``` ``` ## [1] "12 hombres sin piedad" ## [2] "¡Qué bello es vivir!" ## [3] "¿Teléfono rojo? Volamos hacia Moscú" ## [4] "3 Idiots" ## [5] "2001: Una odisea del espacio" ## [6] "¡Olvídate de mí!" ## [7] "1917" ## [8] "12 años de esclavitud" ``` ] --- class: center, middle background-color: rosybrown # ¿Qué títulos tienen mayúsculas además de la primera letra? ## Forma 1: con el comando `gregexpr()` --- # ¿Qué títulos tienen mayúsculas además de la primera letra? .scrollable[ ```r pos.mayusculas <- gregexpr(imdb$Pelicula, pattern = "[[:upper:]]") pos.mayusculas ``` ``` ## [[1]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[2]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[3]] ## [1] 1 13 19 20 ## attr(,"match.length") ## [1] 1 1 1 1 ## ## [[4]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[5]] ## [1] -1 ## attr(,"match.length") ## [1] -1 ## ## [[6]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[7]] ## [1] 1 26 ## attr(,"match.length") ## [1] 1 1 ## ## [[8]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[9]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[10]] ## [1] 1 26 ## attr(,"match.length") ## [1] 1 1 ## ## [[11]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[12]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[13]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[14]] ## [1] 1 26 ## attr(,"match.length") ## [1] 1 1 ## ## [[15]] ## [1] 1 4 ## attr(,"match.length") ## [1] 1 1 ## ## [[16]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[17]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[18]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[19]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[20]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[21]] ## [1] 1 8 13 16 20 ## attr(,"match.length") ## [1] 1 1 1 1 1 ## ## [[22]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[23]] ## [1] 1 11 ## attr(,"match.length") ## [1] 1 1 ## ## [[24]] ## [1] 2 ## attr(,"match.length") ## [1] 1 ## ## [[25]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[26]] ## [1] 1 19 ## attr(,"match.length") ## [1] 1 1 ## ## [[27]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[28]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[29]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[30]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[31]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[32]] ## [1] 1 17 ## attr(,"match.length") ## [1] 1 1 ## ## [[33]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[34]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[35]] ## [1] 1 15 ## attr(,"match.length") ## [1] 1 1 ## ## [[36]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[37]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[38]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[39]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[40]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[41]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[42]] ## [1] 1 10 18 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[43]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[44]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[45]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[46]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[47]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[48]] ## [1] 1 17 ## attr(,"match.length") ## [1] 1 1 ## ## [[49]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[50]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[51]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[52]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[53]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[54]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[55]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[56]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[57]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[58]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[59]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[60]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[61]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[62]] ## [1] 1 2 3 4 6 ## attr(,"match.length") ## [1] 1 1 1 1 1 ## ## [[63]] ## [1] 1 13 22 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[64]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[65]] ## [1] 1 8 13 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[66]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[67]] ## [1] 2 17 31 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[68]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[69]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[70]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[71]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[72]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[73]] ## [1] 1 22 ## attr(,"match.length") ## [1] 1 1 ## ## [[74]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[75]] ## [1] 1 18 ## attr(,"match.length") ## [1] 1 1 ## ## [[76]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[77]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[78]] ## [1] 1 15 19 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[79]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[80]] ## [1] 3 ## attr(,"match.length") ## [1] 1 ## ## [[81]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[82]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[83]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[84]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[85]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[86]] ## [1] 1 14 19 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[87]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[88]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[89]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[90]] ## [1] 7 ## attr(,"match.length") ## [1] 1 ## ## [[91]] ## [1] 1 11 ## attr(,"match.length") ## [1] 1 1 ## ## [[92]] ## [1] 1 7 14 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[93]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[94]] ## [1] 1 18 ## attr(,"match.length") ## [1] 1 1 ## ## [[95]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[96]] ## [1] 1 11 ## attr(,"match.length") ## [1] 1 1 ## ## [[97]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[98]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[99]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[100]] ## [1] 2 ## attr(,"match.length") ## [1] 1 ## ## [[101]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[102]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[103]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[104]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[105]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[106]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[107]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[108]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[109]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[110]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[111]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[112]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[113]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[114]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[115]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[116]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[117]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[118]] ## [1] -1 ## attr(,"match.length") ## [1] -1 ## ## [[119]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[120]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[121]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[122]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[123]] ## [1] 1 8 18 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[124]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[125]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[126]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[127]] ## [1] 1 3 6 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[128]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[129]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[130]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[131]] ## [1] 1 7 ## attr(,"match.length") ## [1] 1 1 ## ## [[132]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[133]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[134]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[135]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[136]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[137]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[138]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[139]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[140]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[141]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[142]] ## [1] 1 12 17 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[143]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[144]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[145]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[146]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[147]] ## [1] 1 14 21 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[148]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[149]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[150]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[151]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[152]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[153]] ## [1] 1 11 ## attr(,"match.length") ## [1] 1 1 ## ## [[154]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[155]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[156]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[157]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[158]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[159]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[160]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[161]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[162]] ## [1] 1 7 14 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[163]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[164]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[165]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[166]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[167]] ## [1] 1 10 16 23 ## attr(,"match.length") ## [1] 1 1 1 1 ## ## [[168]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[169]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[170]] ## [1] 1 13 21 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[171]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[172]] ## [1] 1 7 ## attr(,"match.length") ## [1] 1 1 ## ## [[173]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[174]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[175]] ## [1] 1 24 ## attr(,"match.length") ## [1] 1 1 ## ## [[176]] ## [1] 1 12 19 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[177]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[178]] ## [1] 1 6 12 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[179]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[180]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[181]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[182]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[183]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[184]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[185]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[186]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[187]] ## [1] 1 15 ## attr(,"match.length") ## [1] 1 1 ## ## [[188]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[189]] ## [1] 1 12 21 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[190]] ## [1] 1 18 21 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[191]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[192]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[193]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[194]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[195]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[196]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[197]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[198]] ## [1] 1 7 ## attr(,"match.length") ## [1] 1 1 ## ## [[199]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[200]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[201]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[202]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[203]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[204]] ## [1] 1 14 23 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[205]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[206]] ## [1] 1 4 ## attr(,"match.length") ## [1] 1 1 ## ## [[207]] ## [1] -1 ## attr(,"match.length") ## [1] -1 ## ## [[208]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[209]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[210]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[211]] ## [1] 1 7 20 36 45 ## attr(,"match.length") ## [1] 1 1 1 1 1 ## ## [[212]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[213]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[214]] ## [1] 1 5 10 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[215]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[216]] ## [1] 1 9 16 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[217]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[218]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[219]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[220]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[221]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[222]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[223]] ## [1] 1 3 10 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[224]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[225]] ## [1] 1 20 ## attr(,"match.length") ## [1] 1 1 ## ## [[226]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[227]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[228]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[229]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[230]] ## [1] 1 12 14 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[231]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[232]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[233]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[234]] ## [1] 1 7 ## attr(,"match.length") ## [1] 1 1 ## ## [[235]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[236]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[237]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[238]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[239]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[240]] ## [1] 1 14 24 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[241]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[242]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[243]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[244]] ## [1] 1 26 37 45 58 63 ## attr(,"match.length") ## [1] 1 1 1 1 1 1 ## ## [[245]] ## [1] 1 15 ## attr(,"match.length") ## [1] 1 1 ## ## [[246]] ## [1] 1 15 ## attr(,"match.length") ## [1] 1 1 ## ## [[247]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[248]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[249]] ## [1] 1 6 14 26 30 37 ## attr(,"match.length") ## [1] 1 1 1 1 1 1 ## ## [[250]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ``` ] --- # ¿Qué títulos tienen mayúsculas además de la primera letra? .scrollable[ ```r pos.mayusculas <- gregexpr(imdb$Pelicula, pattern = "[[:upper:]]") *sapply(pos.mayusculas, length) ``` ``` ## [1] 1 1 4 1 1 2 2 2 1 2 1 2 1 2 2 1 1 1 1 1 5 1 2 1 1 2 1 1 2 1 ## [31] 1 2 1 1 2 1 1 1 1 1 1 3 1 2 1 1 1 2 1 1 1 2 1 2 1 1 1 1 1 1 ## [61] 1 5 3 1 3 1 3 2 2 1 2 1 2 2 2 2 1 3 1 1 2 1 2 1 1 3 1 1 2 1 ## [91] 2 3 2 2 1 2 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 ## [121] 2 1 3 1 2 1 3 1 1 1 2 1 1 1 1 1 2 1 2 2 1 3 1 1 1 1 3 1 1 1 ## [151] 1 1 2 2 2 1 1 1 1 1 1 3 1 1 1 2 4 1 1 3 2 2 1 1 2 3 2 3 1 1 ## [181] 2 1 1 1 1 1 2 1 3 3 2 1 1 2 1 1 1 2 1 1 1 1 1 3 1 2 1 1 2 1 ## [211] 5 2 1 3 1 3 1 1 1 1 1 1 3 1 2 2 1 1 1 3 1 2 1 2 1 1 1 1 1 3 ## [241] 1 1 2 6 2 2 1 2 6 1 ``` ] --- # ¿Qué títulos tienen mayúsculas además de la primera letra? .scrollable[ ```r pos.mayusculas <- gregexpr(imdb$Pelicula, pattern = "[[:upper:]]") *sapply(pos.mayusculas, length) > 1 ``` ``` ## [1] FALSE FALSE TRUE FALSE FALSE TRUE TRUE TRUE FALSE TRUE ## [11] FALSE TRUE FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE ## [21] TRUE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE ## [31] FALSE TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE ## [41] FALSE TRUE FALSE TRUE FALSE FALSE FALSE TRUE FALSE FALSE ## [51] FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE ## [61] FALSE TRUE TRUE FALSE TRUE FALSE TRUE TRUE TRUE FALSE ## [71] TRUE FALSE TRUE TRUE TRUE TRUE FALSE TRUE FALSE FALSE ## [81] TRUE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE ## [91] TRUE TRUE TRUE TRUE FALSE TRUE FALSE FALSE FALSE FALSE ## [101] TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE ## [111] FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE ## [121] TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE FALSE FALSE ## [131] TRUE FALSE FALSE FALSE FALSE FALSE TRUE FALSE TRUE TRUE ## [141] FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE ## [151] FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE ## [161] FALSE TRUE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE ## [171] TRUE TRUE FALSE FALSE TRUE TRUE TRUE TRUE FALSE FALSE ## [181] TRUE FALSE FALSE FALSE FALSE FALSE TRUE FALSE TRUE TRUE ## [191] TRUE FALSE FALSE TRUE FALSE FALSE FALSE TRUE FALSE FALSE ## [201] FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE TRUE FALSE ## [211] TRUE TRUE FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE ## [221] FALSE FALSE TRUE FALSE TRUE TRUE FALSE FALSE FALSE TRUE ## [231] FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE TRUE ## [241] FALSE FALSE TRUE TRUE TRUE TRUE FALSE TRUE TRUE FALSE ``` ] --- # ¿Qué títulos tienen mayúsculas además de la primera letra? .scrollable[ ```r pos.mayusculas <- gregexpr(imdb$Pelicula, pattern = "[[:upper:]]") *imdb$Pelicula[sapply(pos.mayusculas, length) > 1] ``` ``` ## [1] "El padrino: Parte II" ## [2] "La lista de Schindler" ## [3] "El señor de los anillos: El retorno del rey" ## [4] "Pulp Fiction" ## [5] "El señor de los anillos: La comunidad del anillo" ## [6] "Forrest Gump" ## [7] "El señor de los anillos: Las dos torres" ## [8] "El Imperio contraataca" ## [9] "Spider-Man: No Way Home" ## [10] "Ciudad de Dios" ## [11] "Salvar al soldado Ryan" ## [12] "El viaje de Chihiro" ## [13] "El profesional (Léon)" ## [14] "Terminator 2: El juicio final" ## [15] "American History X" ## [16] "Gladiator (El gladiador)" ## [17] "El truco final (El prestigio)" ## [18] "Cinema Paradiso" ## [19] "Apocalypse Now" ## [20] "WALL·E" ## [21] "Vengadores: Infinity War" ## [22] "Spider-Man: Un nuevo universo" ## [23] "¿Teléfono rojo? Volamos hacia Moscú" ## [24] "La princesa Mononoke" ## [25] "Old Boy" ## [26] "Your Name." ## [27] "El caballero oscuro: La leyenda renace" ## [28] "Aliens: El regreso" ## [29] "Érase una vez en América" ## [30] "Vengadores: Endgame" ## [31] "El submarino (Das Boot)" ## [32] "Toy Story" ## [33] "American Beauty" ## [34] "El indomable Will Hunting" ## [35] "Masacre (Ven y mira)" ## [36] "Reservoir Dogs" ## [37] "Taare Zameen Par" ## [38] "Vértigo (De entre los muertos)" ## [39] "M, el vampiro de Düsseldorf" ## [40] "Ciudadano Kane" ## [41] "Ikiru (Vivir)" ## [42] "Lawrence de Arabia" ## [43] "Nader y Simin, una separación" ## [44] "Taxi Driver" ## [45] "Toy Story 3" ## [46] "Pather Panchali (La canción del camino)" ## [47] "Indiana Jones y la última cruzada" ## [48] "L.A. Confidential" ## [49] "Green Book" ## [50] "Batman Begins" ## [51] "Children of Heaven" ## [52] "Jai Bhim" ## [53] "El lobo de Wall Street" ## [54] "El tesoro de Sierra Madre" ## [55] "Mi vecino Totoro" ## [56] "Shutter Island" ## [57] "Lock & Stock" ## [58] "Dersu Uzala (El cazador)" ## [59] "El show de Truman" ## [60] "Jurassic Park (Parque Jurásico)" ## [61] "Memories of Murder (Crónica de un asesino en serie)" ## [62] "V de Vendetta" ## [63] "Blade Runner" ## [64] "El puente sobre el río Kwai" ## [65] "Del revés (Inside Out)" ## [66] "Buscando a Nemo" ## [67] "Kill Bill: Volumen 1" ## [68] "Cuentos de Tokio" ## [69] "El gran hotel Budapest" ## [70] "El moderno Sherlock Holmes" ## [71] "El maquinista de La General" ## [72] "Gran Torino" ## [73] "Mary and Max" ## [74] "Barry Lyndon" ## [75] "La pasión de Juana de Arco" ## [76] "Le Mans '66" ## [77] "El gran Lebowski" ## [78] "Harry Potter y las Reliquias de la Muerte - Parte 2" ## [79] "Ben-Hur" ## [80] "Mad Max: Furia en la carretera" ## [81] "Million Dollar Baby" ## [82] "A Silent Voice" ## [83] "Siempre a tu lado (Hachiko)" ## [84] "Gangs of Wasseypur" ## [85] "Monstruos, S.A." ## [86] "La vida de Brian" ## [87] "Hotel Rwanda" ## [88] "Nausicaä del Valle del Viento" ## [89] "Fanny y Alexander" ## [90] "Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito" ## [91] "La batalla de Argel" ## [92] "Las noches de Cabiria" ## [93] "Andrei Rublev" ## [94] "Neon Genesis Evangelion: The End of Evangelion" ``` ] --- class: center, middle background-color: rosybrown # ¿Qué títulos tienen mayúsculas además de la primera letra? ## Forma 2: con el comando `grep()` --- # ¿Qué títulos tienen mayúsculas además de la primera letra? Comando `grep()` .scrollable[ ```r grep(imdb$Pelicula, pattern = "[[:upper:]]{2,}", value = TRUE) ``` ``` ## [1] "El padrino: Parte II" ## [2] "WALL·E" ``` ] -- <br> .center[.content-box-purple[¿Por qué solo reporta estas?]] -- <br> Porque, con el patrón `[[:upper:]]{2,}`, solo devuelve los títulos que tienen al menos dos mayúsculas JUNTAS. --- # ¿Qué títulos tienen mayúsculas además de la primera letra? Comando `grep()` Teniendo en cuenta que, en el reconocimiento de patrones: * `.` coincide con cualquier caracter simple, * `*` significa que aparezca al menos 0 veces. .scroll-small2[ ```r grep(imdb$Pelicula, pattern = "[[:upper:]].*[[:upper:]]", value = TRUE) ``` ``` ## [1] "El padrino: Parte II" ## [2] "La lista de Schindler" ## [3] "El señor de los anillos: El retorno del rey" ## [4] "Pulp Fiction" ## [5] "El señor de los anillos: La comunidad del anillo" ## [6] "Forrest Gump" ## [7] "El señor de los anillos: Las dos torres" ## [8] "El Imperio contraataca" ## [9] "Spider-Man: No Way Home" ## [10] "Ciudad de Dios" ## [11] "Salvar al soldado Ryan" ## [12] "El viaje de Chihiro" ## [13] "El profesional (Léon)" ## [14] "Terminator 2: El juicio final" ## [15] "American History X" ## [16] "Gladiator (El gladiador)" ## [17] "El truco final (El prestigio)" ## [18] "Cinema Paradiso" ## [19] "Apocalypse Now" ## [20] "WALL·E" ## [21] "Vengadores: Infinity War" ## [22] "Spider-Man: Un nuevo universo" ## [23] "¿Teléfono rojo? Volamos hacia Moscú" ## [24] "La princesa Mononoke" ## [25] "Old Boy" ## [26] "Your Name." ## [27] "El caballero oscuro: La leyenda renace" ## [28] "Aliens: El regreso" ## [29] "Érase una vez en América" ## [30] "Vengadores: Endgame" ## [31] "El submarino (Das Boot)" ## [32] "Toy Story" ## [33] "American Beauty" ## [34] "El indomable Will Hunting" ## [35] "Masacre (Ven y mira)" ## [36] "Reservoir Dogs" ## [37] "Taare Zameen Par" ## [38] "Vértigo (De entre los muertos)" ## [39] "M, el vampiro de Düsseldorf" ## [40] "Ciudadano Kane" ## [41] "Ikiru (Vivir)" ## [42] "Lawrence de Arabia" ## [43] "Nader y Simin, una separación" ## [44] "Taxi Driver" ## [45] "Toy Story 3" ## [46] "Pather Panchali (La canción del camino)" ## [47] "Indiana Jones y la última cruzada" ## [48] "L.A. Confidential" ## [49] "Green Book" ## [50] "Batman Begins" ## [51] "Children of Heaven" ## [52] "Jai Bhim" ## [53] "El lobo de Wall Street" ## [54] "El tesoro de Sierra Madre" ## [55] "Mi vecino Totoro" ## [56] "Shutter Island" ## [57] "Lock & Stock" ## [58] "Dersu Uzala (El cazador)" ## [59] "El show de Truman" ## [60] "Jurassic Park (Parque Jurásico)" ## [61] "Memories of Murder (Crónica de un asesino en serie)" ## [62] "V de Vendetta" ## [63] "Blade Runner" ## [64] "El puente sobre el río Kwai" ## [65] "Del revés (Inside Out)" ## [66] "Buscando a Nemo" ## [67] "Kill Bill: Volumen 1" ## [68] "Cuentos de Tokio" ## [69] "El gran hotel Budapest" ## [70] "El moderno Sherlock Holmes" ## [71] "El maquinista de La General" ## [72] "Gran Torino" ## [73] "Mary and Max" ## [74] "Barry Lyndon" ## [75] "La pasión de Juana de Arco" ## [76] "Le Mans '66" ## [77] "El gran Lebowski" ## [78] "Harry Potter y las Reliquias de la Muerte - Parte 2" ## [79] "Ben-Hur" ## [80] "Mad Max: Furia en la carretera" ## [81] "Million Dollar Baby" ## [82] "A Silent Voice" ## [83] "Siempre a tu lado (Hachiko)" ## [84] "Gangs of Wasseypur" ## [85] "Monstruos, S.A." ## [86] "La vida de Brian" ## [87] "Hotel Rwanda" ## [88] "Nausicaä del Valle del Viento" ## [89] "Fanny y Alexander" ## [90] "Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito" ## [91] "La batalla de Argel" ## [92] "Las noches de Cabiria" ## [93] "Andrei Rublev" ## [94] "Neon Genesis Evangelion: The End of Evangelion" ``` ] --- class: center, middle background-color: rosybrown # ¿Cómo obtener las letras mayúsculas de los títulos de las películas? --- # ¿Cómo obtener las letras mayúsculas de los títulos de las películas? .scrollable[ ```r pos.mayusculas <- gregexpr(imdb$Pelicula, pattern = "[[:upper:]]") pos.mayusculas ``` ``` ## [[1]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[2]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[3]] ## [1] 1 13 19 20 ## attr(,"match.length") ## [1] 1 1 1 1 ## ## [[4]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[5]] ## [1] -1 ## attr(,"match.length") ## [1] -1 ## ## [[6]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[7]] ## [1] 1 26 ## attr(,"match.length") ## [1] 1 1 ## ## [[8]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[9]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[10]] ## [1] 1 26 ## attr(,"match.length") ## [1] 1 1 ## ## [[11]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[12]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[13]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[14]] ## [1] 1 26 ## attr(,"match.length") ## [1] 1 1 ## ## [[15]] ## [1] 1 4 ## attr(,"match.length") ## [1] 1 1 ## ## [[16]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[17]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[18]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[19]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[20]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[21]] ## [1] 1 8 13 16 20 ## attr(,"match.length") ## [1] 1 1 1 1 1 ## ## [[22]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[23]] ## [1] 1 11 ## attr(,"match.length") ## [1] 1 1 ## ## [[24]] ## [1] 2 ## attr(,"match.length") ## [1] 1 ## ## [[25]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[26]] ## [1] 1 19 ## attr(,"match.length") ## [1] 1 1 ## ## [[27]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[28]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[29]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[30]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[31]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[32]] ## [1] 1 17 ## attr(,"match.length") ## [1] 1 1 ## ## [[33]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[34]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[35]] ## [1] 1 15 ## attr(,"match.length") ## [1] 1 1 ## ## [[36]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[37]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[38]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[39]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[40]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[41]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[42]] ## [1] 1 10 18 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[43]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[44]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[45]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[46]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[47]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[48]] ## [1] 1 17 ## attr(,"match.length") ## [1] 1 1 ## ## [[49]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[50]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[51]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[52]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[53]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[54]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[55]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[56]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[57]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[58]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[59]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[60]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[61]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[62]] ## [1] 1 2 3 4 6 ## attr(,"match.length") ## [1] 1 1 1 1 1 ## ## [[63]] ## [1] 1 13 22 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[64]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[65]] ## [1] 1 8 13 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[66]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[67]] ## [1] 2 17 31 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[68]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[69]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[70]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[71]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[72]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[73]] ## [1] 1 22 ## attr(,"match.length") ## [1] 1 1 ## ## [[74]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[75]] ## [1] 1 18 ## attr(,"match.length") ## [1] 1 1 ## ## [[76]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[77]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[78]] ## [1] 1 15 19 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[79]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[80]] ## [1] 3 ## attr(,"match.length") ## [1] 1 ## ## [[81]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[82]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[83]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[84]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[85]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[86]] ## [1] 1 14 19 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[87]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[88]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[89]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[90]] ## [1] 7 ## attr(,"match.length") ## [1] 1 ## ## [[91]] ## [1] 1 11 ## attr(,"match.length") ## [1] 1 1 ## ## [[92]] ## [1] 1 7 14 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[93]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[94]] ## [1] 1 18 ## attr(,"match.length") ## [1] 1 1 ## ## [[95]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[96]] ## [1] 1 11 ## attr(,"match.length") ## [1] 1 1 ## ## [[97]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[98]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[99]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[100]] ## [1] 2 ## attr(,"match.length") ## [1] 1 ## ## [[101]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[102]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[103]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[104]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[105]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[106]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[107]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[108]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[109]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[110]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[111]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[112]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[113]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[114]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[115]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[116]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[117]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[118]] ## [1] -1 ## attr(,"match.length") ## [1] -1 ## ## [[119]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[120]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[121]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[122]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[123]] ## [1] 1 8 18 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[124]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[125]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[126]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[127]] ## [1] 1 3 6 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[128]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[129]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[130]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[131]] ## [1] 1 7 ## attr(,"match.length") ## [1] 1 1 ## ## [[132]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[133]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[134]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[135]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[136]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[137]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[138]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[139]] ## [1] 1 13 ## attr(,"match.length") ## [1] 1 1 ## ## [[140]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[141]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[142]] ## [1] 1 12 17 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[143]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[144]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[145]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[146]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[147]] ## [1] 1 14 21 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[148]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[149]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[150]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[151]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[152]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[153]] ## [1] 1 11 ## attr(,"match.length") ## [1] 1 1 ## ## [[154]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[155]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[156]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[157]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[158]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[159]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[160]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[161]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[162]] ## [1] 1 7 14 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[163]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[164]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[165]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[166]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[167]] ## [1] 1 10 16 23 ## attr(,"match.length") ## [1] 1 1 1 1 ## ## [[168]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[169]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[170]] ## [1] 1 13 21 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[171]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[172]] ## [1] 1 7 ## attr(,"match.length") ## [1] 1 1 ## ## [[173]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[174]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[175]] ## [1] 1 24 ## attr(,"match.length") ## [1] 1 1 ## ## [[176]] ## [1] 1 12 19 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[177]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[178]] ## [1] 1 6 12 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[179]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[180]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[181]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[182]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[183]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[184]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[185]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[186]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[187]] ## [1] 1 15 ## attr(,"match.length") ## [1] 1 1 ## ## [[188]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[189]] ## [1] 1 12 21 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[190]] ## [1] 1 18 21 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[191]] ## [1] 1 6 ## attr(,"match.length") ## [1] 1 1 ## ## [[192]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[193]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[194]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[195]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[196]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[197]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[198]] ## [1] 1 7 ## attr(,"match.length") ## [1] 1 1 ## ## [[199]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[200]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[201]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[202]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[203]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[204]] ## [1] 1 14 23 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[205]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[206]] ## [1] 1 4 ## attr(,"match.length") ## [1] 1 1 ## ## [[207]] ## [1] -1 ## attr(,"match.length") ## [1] -1 ## ## [[208]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[209]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[210]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[211]] ## [1] 1 7 20 36 45 ## attr(,"match.length") ## [1] 1 1 1 1 1 ## ## [[212]] ## [1] 1 5 ## attr(,"match.length") ## [1] 1 1 ## ## [[213]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[214]] ## [1] 1 5 10 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[215]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[216]] ## [1] 1 9 16 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[217]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[218]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[219]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[220]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[221]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[222]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[223]] ## [1] 1 3 10 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[224]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[225]] ## [1] 1 20 ## attr(,"match.length") ## [1] 1 1 ## ## [[226]] ## [1] 1 10 ## attr(,"match.length") ## [1] 1 1 ## ## [[227]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[228]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[229]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[230]] ## [1] 1 12 14 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[231]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[232]] ## [1] 1 12 ## attr(,"match.length") ## [1] 1 1 ## ## [[233]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[234]] ## [1] 1 7 ## attr(,"match.length") ## [1] 1 1 ## ## [[235]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[236]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[237]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[238]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[239]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[240]] ## [1] 1 14 24 ## attr(,"match.length") ## [1] 1 1 1 ## ## [[241]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[242]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[243]] ## [1] 1 9 ## attr(,"match.length") ## [1] 1 1 ## ## [[244]] ## [1] 1 26 37 45 58 63 ## attr(,"match.length") ## [1] 1 1 1 1 1 1 ## ## [[245]] ## [1] 1 15 ## attr(,"match.length") ## [1] 1 1 ## ## [[246]] ## [1] 1 15 ## attr(,"match.length") ## [1] 1 1 ## ## [[247]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ## ## [[248]] ## [1] 1 8 ## attr(,"match.length") ## [1] 1 1 ## ## [[249]] ## [1] 1 6 14 26 30 37 ## attr(,"match.length") ## [1] 1 1 1 1 1 1 ## ## [[250]] ## [1] 1 ## attr(,"match.length") ## [1] 1 ``` ] --- # ¿Cómo obtener las letras mayúsculas de los títulos de las películas? .scrollable[ ```r pos.mayusculas <- gregexpr(imdb$Pelicula, pattern = "[[:upper:]]") ``` ] Por ejemplo, de la tercera película de la lista: .scroll-small2[ ```r pos.mayusculas[[3]] ``` ``` ## [1] 1 13 19 20 ## attr(,"match.length") ## [1] 1 1 1 1 ``` ```r strsplit(imdb$Pelicula[3], "")[[1]] ``` ``` ## [1] "E" "l" " " "p" "a" "d" "r" "i" "n" "o" ":" " " "P" "a" "r" ## [16] "t" "e" " " "I" "I" ``` ```r strsplit(imdb$Pelicula[3], "")[[1]][pos.mayusculas[[3]]] ``` ``` ## [1] "E" "P" "I" "I" ``` ] --- # ¿Cómo obtener las letras mayúsculas de los títulos de las películas? .scrollable[ ```r que.mayusculas <- lapply(1:250, function(i){ if(any(pos.mayusculas[[i]] == -1)){ "No tiene letras mayúsculas." }else{ strsplit(imdb$Pelicula[i], "")[[1]][pos.mayusculas[[i]]] } }) names(que.mayusculas) <- imdb$Pelicula que.mayusculas ``` ``` ## $`Cadena perpetua` ## [1] "C" ## ## $`El padrino` ## [1] "E" ## ## $`El padrino: Parte II` ## [1] "E" "P" "I" "I" ## ## $`El caballero oscuro` ## [1] "E" ## ## $`12 hombres sin piedad` ## [1] "No tiene letras mayúsculas." ## ## $`La lista de Schindler` ## [1] "L" "S" ## ## $`El señor de los anillos: El retorno del rey` ## [1] "E" "E" ## ## $`Pulp Fiction` ## [1] "P" "F" ## ## $`El bueno, el feo y el malo` ## [1] "E" ## ## $`El señor de los anillos: La comunidad del anillo` ## [1] "E" "L" ## ## $`El club de la lucha` ## [1] "E" ## ## $`Forrest Gump` ## [1] "F" "G" ## ## $Origen ## [1] "O" ## ## $`El señor de los anillos: Las dos torres` ## [1] "E" "L" ## ## $`El Imperio contraataca` ## [1] "E" "I" ## ## $Matrix ## [1] "M" ## ## $`Uno de los nuestros` ## [1] "U" ## ## $`Alguien voló sobre el nido del cuco` ## [1] "A" ## ## $`Los siete samuráis` ## [1] "L" ## ## $Seven ## [1] "S" ## ## $`Spider-Man: No Way Home` ## [1] "S" "M" "N" "W" "H" ## ## $`El silencio de los corderos` ## [1] "E" ## ## $`Ciudad de Dios` ## [1] "C" "D" ## ## $`¡Qué bello es vivir!` ## [1] "Q" ## ## $`La vida es bella` ## [1] "L" ## ## $`Salvar al soldado Ryan` ## [1] "S" "R" ## ## $`La guerra de las galaxias` ## [1] "L" ## ## $Interstellar ## [1] "I" ## ## $`El viaje de Chihiro` ## [1] "E" "C" ## ## $`La milla verde` ## [1] "L" ## ## $Parásitos ## [1] "P" ## ## $`El profesional (Léon)` ## [1] "E" "L" ## ## $Harakiri ## [1] "H" ## ## $`El pianista` ## [1] "E" ## ## $`Terminator 2: El juicio final` ## [1] "T" "E" ## ## $`Regreso al futuro` ## [1] "R" ## ## $`Sospechosos habituales` ## [1] "S" ## ## $Psicosis ## [1] "P" ## ## $`El rey león` ## [1] "E" ## ## $`Tiempos modernos` ## [1] "T" ## ## $`La tumba de las luciérnagas` ## [1] "L" ## ## $`American History X` ## [1] "A" "H" "X" ## ## $Whiplash ## [1] "W" ## ## $`Gladiator (El gladiador)` ## [1] "G" "E" ## ## $`Luces de la ciudad` ## [1] "L" ## ## $Infiltrados ## [1] "I" ## ## $Intocable ## [1] "I" ## ## $`El truco final (El prestigio)` ## [1] "E" "E" ## ## $Casablanca ## [1] "C" ## ## $`Hasta que llegó su hora` ## [1] "H" ## ## $`La ventana indiscreta` ## [1] "L" ## ## $`Cinema Paradiso` ## [1] "C" "P" ## ## $`Alien, el octavo pasajero` ## [1] "A" ## ## $`Apocalypse Now` ## [1] "A" "N" ## ## $Memento ## [1] "M" ## ## $`En busca del arca perdida` ## [1] "E" ## ## $`El gran dictador` ## [1] "E" ## ## $`Django desencadenado` ## [1] "D" ## ## $`La vida de los otros` ## [1] "L" ## ## $`Senderos de gloria` ## [1] "S" ## ## $`El crepúsculo de los dioses` ## [1] "E" ## ## $`WALL·E` ## [1] "W" "A" "L" "L" "E" ## ## $`Vengadores: Infinity War` ## [1] "V" "I" "W" ## ## $`Testigo de cargo` ## [1] "T" ## ## $`Spider-Man: Un nuevo universo` ## [1] "S" "M" "U" ## ## $`El resplandor` ## [1] "E" ## ## $`¿Teléfono rojo? Volamos hacia Moscú` ## [1] "T" "V" "M" ## ## $`La princesa Mononoke` ## [1] "L" "M" ## ## $`Old Boy` ## [1] "O" "B" ## ## $Joker ## [1] "J" ## ## $`Your Name.` ## [1] "Y" "N" ## ## $Coco ## [1] "C" ## ## $`El caballero oscuro: La leyenda renace` ## [1] "E" "L" ## ## $`Aliens: El regreso` ## [1] "A" "E" ## ## $`Érase una vez en América` ## [1] "É" "A" ## ## $`Vengadores: Endgame` ## [1] "V" "E" ## ## $Cafarnaúm ## [1] "C" ## ## $`El submarino (Das Boot)` ## [1] "E" "D" "B" ## ## $`El infierno del odio` ## [1] "E" ## ## $`3 Idiots` ## [1] "I" ## ## $`Toy Story` ## [1] "T" "S" ## ## $Amadeus ## [1] "A" ## ## $`American Beauty` ## [1] "A" "B" ## ## $Braveheart ## [1] "B" ## ## $`Malditos bastardos` ## [1] "M" ## ## $`El indomable Will Hunting` ## [1] "E" "W" "H" ## ## $Hamilton ## [1] "H" ## ## $`El retorno del jedi` ## [1] "E" ## ## $`Masacre (Ven y mira)` ## [1] "M" "V" ## ## $`2001: Una odisea del espacio` ## [1] "U" ## ## $`Reservoir Dogs` ## [1] "R" "D" ## ## $`Taare Zameen Par` ## [1] "T" "Z" "P" ## ## $`Vértigo (De entre los muertos)` ## [1] "V" "D" ## ## $`M, el vampiro de Düsseldorf` ## [1] "M" "D" ## ## $`La caza` ## [1] "L" ## ## $`Ciudadano Kane` ## [1] "C" "K" ## ## $`Réquiem por un sueño` ## [1] "R" ## ## $`Cantando bajo la lluvia` ## [1] "C" ## ## $`Con la muerte en los talones` ## [1] "C" ## ## $`¡Olvídate de mí!` ## [1] "O" ## ## $`Ikiru (Vivir)` ## [1] "I" "V" ## ## $`Ladrón de bicicletas` ## [1] "L" ## ## $`Lawrence de Arabia` ## [1] "L" "A" ## ## $`El chico` ## [1] "E" ## ## $`La chaqueta metálica` ## [1] "L" ## ## $Incendios ## [1] "I" ## ## $Dangal ## [1] "D" ## ## $`El apartamento` ## [1] "E" ## ## $Perdición ## [1] "P" ## ## $Metrópolis ## [1] "M" ## ## $`El padre` ## [1] "E" ## ## $`Nader y Simin, una separación` ## [1] "N" "S" ## ## $`Taxi Driver` ## [1] "T" "D" ## ## $`La naranja mecánica` ## [1] "L" ## ## $`El golpe` ## [1] "E" ## ## $`El precio del poder` ## [1] "E" ## ## $`Snatch, cerdos y diamantes` ## [1] "S" ## ## $`1917` ## [1] "No tiene letras mayúsculas." ## ## $Amelie ## [1] "A" ## ## $`Matar a un ruiseñor` ## [1] "M" ## ## $`Toy Story 3` ## [1] "T" "S" ## ## $`La muerte tenía un precio` ## [1] "L" ## ## $`Pather Panchali (La canción del camino)` ## [1] "P" "P" "L" ## ## $Up ## [1] "U" ## ## $`Indiana Jones y la última cruzada` ## [1] "I" "J" ## ## $Heat ## [1] "H" ## ## $`L.A. Confidential` ## [1] "L" "A" "C" ## ## $Ran ## [1] "R" ## ## $Yojimbo ## [1] "Y" ## ## $`Jungla de cristal` ## [1] "J" ## ## $`Green Book` ## [1] "G" "B" ## ## $Rashomon ## [1] "R" ## ## $`El hundimiento` ## [1] "E" ## ## $`Eva al desnudo` ## [1] "E" ## ## $`Los caballeros de la mesa cuadrada y sus locos seguidores` ## [1] "L" ## ## $`Con faldas y a lo loco` ## [1] "C" ## ## $`Batman Begins` ## [1] "B" "B" ## ## $`Sin perdón` ## [1] "S" ## ## $`Children of Heaven` ## [1] "C" "H" ## ## $`Jai Bhim` ## [1] "J" "B" ## ## $`El castillo ambulante` ## [1] "E" ## ## $`El lobo de Wall Street` ## [1] "E" "W" "S" ## ## $`Vencedores o vencidos` ## [1] "V" ## ## $`Pozos de ambición` ## [1] "P" ## ## $`La gran evasión` ## [1] "L" ## ## $Casino ## [1] "C" ## ## $`El tesoro de Sierra Madre` ## [1] "E" "S" "M" ## ## $`El laberinto del fauno` ## [1] "E" ## ## $`Una mente maravillosa` ## [1] "U" ## ## $`El secreto de sus ojos` ## [1] "E" ## ## $`Toro salvaje` ## [1] "T" ## ## $Chinatown ## [1] "C" ## ## $`Mi vecino Totoro` ## [1] "M" "T" ## ## $`Shutter Island` ## [1] "S" "I" ## ## $`Lock & Stock` ## [1] "L" "S" ## ## $`No es país para viejos` ## [1] "N" ## ## $Klaus ## [1] "K" ## ## $`Crimen perfecto` ## [1] "C" ## ## $`La quimera del oro` ## [1] "L" ## ## $`La cosa` ## [1] "L" ## ## $`Tres anuncios en las afueras` ## [1] "T" ## ## $`Dersu Uzala (El cazador)` ## [1] "D" "U" "E" ## ## $`El séptimo sello` ## [1] "E" ## ## $`El hombre elefante` ## [1] "E" ## ## $`El sexto sentido` ## [1] "E" ## ## $`El show de Truman` ## [1] "E" "T" ## ## $`Jurassic Park (Parque Jurásico)` ## [1] "J" "P" "P" "J" ## ## $`Fresas salvajes` ## [1] "F" ## ## $`El tercer hombre` ## [1] "E" ## ## $`Memories of Murder (Crónica de un asesino en serie)` ## [1] "M" "M" "C" ## ## $`V de Vendetta` ## [1] "V" "V" ## ## $`Blade Runner` ## [1] "B" "R" ## ## $Trainspotting ## [1] "T" ## ## $Fargo ## [1] "F" ## ## $`El puente sobre el río Kwai` ## [1] "E" "K" ## ## $`Del revés (Inside Out)` ## [1] "D" "I" "O" ## ## $`Buscando a Nemo` ## [1] "B" "N" ## ## $`Kill Bill: Volumen 1` ## [1] "K" "B" "V" ## ## $Warrior ## [1] "W" ## ## $`Lo que el viento se llevó` ## [1] "L" ## ## $`Cuentos de Tokio` ## [1] "C" "T" ## ## $`La ley del silencio` ## [1] "L" ## ## $`Mi padre y mi hijo` ## [1] "M" ## ## $`Relatos salvajes` ## [1] "R" ## ## $Prisioneros ## [1] "P" ## ## $Stalker ## [1] "S" ## ## $`El gran hotel Budapest` ## [1] "E" "B" ## ## $`El cazador` ## [1] "E" ## ## $`El moderno Sherlock Holmes` ## [1] "E" "S" "H" ## ## $`El maquinista de La General` ## [1] "E" "L" "G" ## ## $`Gran Torino` ## [1] "G" "T" ## ## $Persona ## [1] "P" ## ## $`Antes de amanecer` ## [1] "A" ## ## $`Mary and Max` ## [1] "M" "M" ## ## $`Atrápame si puedes` ## [1] "A" ## ## $Dune ## [1] "D" ## ## $`Caballero sin espada` ## [1] "C" ## ## $`Barry Lyndon` ## [1] "B" "L" ## ## $Z ## [1] "Z" ## ## $`En el nombre del padre` ## [1] "E" ## ## $`Hasta el último hombre` ## [1] "H" ## ## $Perdida ## [1] "P" ## ## $`La habitación` ## [1] "L" ## ## $`La pasión de Juana de Arco` ## [1] "L" "J" "A" ## ## $Andhadhun ## [1] "A" ## ## $`Le Mans '66` ## [1] "L" "M" ## ## $`12 años de esclavitud` ## [1] "No tiene letras mayúsculas." ## ## $`Ser o no ser` ## [1] "S" ## ## $`El gran Lebowski` ## [1] "E" "L" ## ## $`El club de los poetas muertos` ## [1] "E" ## ## $`Harry Potter y las Reliquias de la Muerte - Parte 2` ## [1] "H" "P" "R" "M" "P" ## ## $`Ben-Hur` ## [1] "B" "H" ## ## $`Cómo entrenar a tu dragón` ## [1] "C" ## ## $`Mad Max: Furia en la carretera` ## [1] "M" "M" "F" ## ## $`Sonata de otoño` ## [1] "S" ## ## $`Million Dollar Baby` ## [1] "M" "D" "B" ## ## $`El salario del miedo` ## [1] "E" ## ## $`Cuenta conmigo` ## [1] "C" ## ## $`La doncella` ## [1] "L" ## ## $`Network, un mundo implacable` ## [1] "N" ## ## $Logan ## [1] "L" ## ## $`El odio` ## [1] "E" ## ## $`A Silent Voice` ## [1] "A" "S" "V" ## ## $`La leyenda del indomable` ## [1] "L" ## ## $`Siempre a tu lado (Hachiko)` ## [1] "S" "H" ## ## $`Gangs of Wasseypur` ## [1] "G" "W" ## ## $`Los cuatrocientos golpes` ## [1] "L" ## ## $Platoon ## [1] "P" ## ## $Spotlight ## [1] "S" ## ## $`Monstruos, S.A.` ## [1] "M" "S" "A" ## ## $Rebeca ## [1] "R" ## ## $`La vida de Brian` ## [1] "L" "B" ## ## $`Deseando amar` ## [1] "D" ## ## $`Hotel Rwanda` ## [1] "H" "R" ## ## $Eskiya ## [1] "E" ## ## $Rush ## [1] "R" ## ## $Rocky ## [1] "R" ## ## $`Amores perros` ## [1] "A" ## ## $`Hacia rutas salvajes` ## [1] "H" ## ## $`Nausicaä del Valle del Viento` ## [1] "N" "V" "V" ## ## $`Sucedió una noche` ## [1] "S" ## ## $`Antes del atardecer` ## [1] "A" ## ## $`Fanny y Alexander` ## [1] "F" "A" ## ## $`Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito` ## [1] "G" "K" "Y" "L" "T" "I" ## ## $`La batalla de Argel` ## [1] "L" "A" ## ## $`Las noches de Cabiria` ## [1] "L" "C" ## ## $Drishyam ## [1] "D" ## ## $`Andrei Rublev` ## [1] "A" "R" ## ## $`Neon Genesis Evangelion: The End of Evangelion` ## [1] "N" "G" "E" "T" "E" "E" ## ## $`La princesa prometida` ## [1] "L" ``` ] --- class: center, middle background-color: rosybrown # ¿Cuáles son las 15 películas más populares, por orden de mayor a menor? --- # ¿Cuáles son las 15 películas más populares, por orden de mayor a menor? .scroll-tiny[ ```r order(imdb$Popularidad, decreasing = TRUE) ``` ``` ## [1] 1 4 13 11 12 8 16 10 7 2 28 73 14 20 58 ## [16] 44 137 85 22 26 142 27 6 48 46 30 154 15 3 55 ## [31] 36 70 83 32 17 171 42 178 62 35 37 166 39 88 84 ## [46] 177 76 124 91 63 18 66 100 165 214 81 202 56 167 156 ## [61] 86 195 149 230 130 53 211 117 47 97 121 114 116 34 43 ## [76] 209 113 187 191 5 172 119 23 9 125 29 105 221 31 213 ## [91] 74 207 176 216 173 25 185 174 148 38 90 54 126 239 155 ## [106] 127 144 69 49 237 118 135 146 201 161 67 51 65 236 210 ## [121] 196 72 179 229 131 24 96 250 21 160 203 228 138 93 82 ## [136] 232 218 59 80 68 141 206 234 133 151 75 19 188 153 50 ## [151] 99 152 95 120 180 193 103 225 41 136 115 242 52 122 78 ## [166] 71 145 112 238 164 98 40 212 57 61 175 150 184 60 92 ## [181] 45 163 107 108 194 224 140 158 110 200 106 169 170 222 240 ## [196] 132 198 102 220 94 109 182 233 157 219 231 186 134 104 147 ## [211] 128 111 64 129 227 192 197 159 168 241 226 190 205 183 87 ## [226] 77 101 143 139 89 223 235 243 217 181 245 204 248 33 249 ## [241] 246 189 244 79 247 208 215 123 199 162 ``` ] ```r order(imdb$Popularidad, decreasing = TRUE)[1:15] ``` ``` ## [1] 1 4 13 11 12 8 16 10 7 2 28 73 14 20 58 ``` -- <br> .center[.content-box-purple[¿Qué películas ocupan las filas anteriores?]] --- # ¿Cuáles son las 15 películas más populares, por orden de mayor a menor? .scrollable[ ```r mas.populares <- imdb$Pelicula[order(imdb$Popularidad, decreasing = TRUE)[1:15]] mas.populares ``` ``` ## [1] "Cadena perpetua" ## [2] "El caballero oscuro" ## [3] "Origen" ## [4] "El club de la lucha" ## [5] "Forrest Gump" ## [6] "Pulp Fiction" ## [7] "Matrix" ## [8] "El señor de los anillos: La comunidad del anillo" ## [9] "El señor de los anillos: El retorno del rey" ## [10] "El padrino" ## [11] "Interstellar" ## [12] "El caballero oscuro: La leyenda renace" ## [13] "El señor de los anillos: Las dos torres" ## [14] "Seven" ## [15] "Django desencadenado" ``` ] --- class: center, middle background-color: rosybrown # ¿Cuáles son las 10 películas con mayor puntuación, por orden de mayor a menor? --- # ¿Cuáles son las 10 películas con mayor puntuación, por orden de mayor a menor? ```r mejor.puntuadas <- head(imdb$Pelicula[order(imdb$Nota, decreasing = TRUE)], 10) mejor.puntuadas ``` ``` ## [1] "Cadena perpetua" ## [2] "El padrino" ## [3] "El padrino: Parte II" ## [4] "El caballero oscuro" ## [5] "12 hombres sin piedad" ## [6] "La lista de Schindler" ## [7] "El señor de los anillos: El retorno del rey" ## [8] "Pulp Fiction" ## [9] "El bueno, el feo y el malo" ## [10] "El señor de los anillos: La comunidad del anillo" ``` --- class: center, middle background-color: rosybrown # ¿Hay alguna película común en las dos listas anteriores, es decir, que esté entre las 15 más populares y las 10 con mayor puntuación? --- # ¿Hay alguna película que esté entre las 15 más populares y las 10 con mayor puntuación? Utilizando los vectores `mas.populares` y `mejor.puntuadas` creados anteriormente como conjuntos con las 15 películas más populares y las 10 con mayor puntuación, respectivamente... ```r intersect(mas.populares, mejor.puntuadas) ``` ``` ## [1] "Cadena perpetua" ## [2] "El caballero oscuro" ## [3] "Pulp Fiction" ## [4] "El señor de los anillos: La comunidad del anillo" ## [5] "El señor de los anillos: El retorno del rey" ## [6] "El padrino" ``` --- class: center, middle background-color: rosybrown # ¿Hay alguna película que esté entre las 10 con mayor puntuación, pero no entre las 15 más populares? --- # ¿Hay alguna película que esté entre las 10 con mayor puntuación, pero no entre las 15 más populares? Utilizando los vectores `mas.populares` y `mejor.puntuadas` creados anteriormente como conjuntos con las 15 películas más populares y las 10 con mayor puntuación, respectivamente... ```r setdiff(mejor.puntuadas, mas.populares) ``` ``` ## [1] "El padrino: Parte II" ## [2] "12 hombres sin piedad" ## [3] "La lista de Schindler" ## [4] "El bueno, el feo y el malo" ``` --- class: center, middle background-color: rosybrown # Hacer un gráfico con las películas cuyo año de lanzamiento es previo al año 1960, ordenadas por año y en el que se indique con una barra la popularidad de cada una. ## Gráfico Popularidad_Peliculas_antes60.pdf --- # Gráfico Popularidad_Peliculas_antes60.pdf ¿Cuáles son los pasos a seguir? -- 1. ¿Qué películas son anteriores a los sesenta? Generar un subconjunto de datos. -- 2. Ordenar el subconjunto de datos anterior según el año de lanzamiento, de más antiguo a más reciente. -- 3. Hacer el gráfico: -- * un diagrama de barras cuya altura es la popularidad de cada película; -- * indicar el título y el año de lanzamiento; -- * colorear las barras según si la popularidad está entre 100000 y 300000 usuarios (naranja), menos de 100000 (amarillo) o más de 300000 (rojo). -- 4. Guardarlo en un PDF con anchura 7 inches (por defecto) y altura 8 inches. --- # 1. ¿Qué películas son anteriores a los sesenta? Generar un subconjunto de datos. .scrollable[ ```r imdb$Pelicula[imdb$Fecha < 1960] ``` ``` ## [1] "12 hombres sin piedad" ## [2] "Los siete samuráis" ## [3] "¡Qué bello es vivir!" ## [4] "Tiempos modernos" ## [5] "Luces de la ciudad" ## [6] "Casablanca" ## [7] "La ventana indiscreta" ## [8] "El gran dictador" ## [9] "Senderos de gloria" ## [10] "El crepúsculo de los dioses" ## [11] "Testigo de cargo" ## [12] "Vértigo (De entre los muertos)" ## [13] "M, el vampiro de Düsseldorf" ## [14] "Ciudadano Kane" ## [15] "Cantando bajo la lluvia" ## [16] "Con la muerte en los talones" ## [17] "Ikiru (Vivir)" ## [18] "Ladrón de bicicletas" ## [19] "El chico" ## [20] "Perdición" ## [21] "Metrópolis" ## [22] "Pather Panchali (La canción del camino)" ## [23] "Rashomon" ## [24] "Eva al desnudo" ## [25] "Con faldas y a lo loco" ## [26] "El tesoro de Sierra Madre" ## [27] "Crimen perfecto" ## [28] "La quimera del oro" ## [29] "El séptimo sello" ## [30] "Fresas salvajes" ## [31] "El tercer hombre" ## [32] "El puente sobre el río Kwai" ## [33] "Lo que el viento se llevó" ## [34] "Cuentos de Tokio" ## [35] "La ley del silencio" ## [36] "El moderno Sherlock Holmes" ## [37] "El maquinista de La General" ## [38] "Caballero sin espada" ## [39] "La pasión de Juana de Arco" ## [40] "Ser o no ser" ## [41] "Ben-Hur" ## [42] "El salario del miedo" ## [43] "Los cuatrocientos golpes" ## [44] "Rebeca" ## [45] "Sucedió una noche" ## [46] "Las noches de Cabiria" ``` ] --- # 1. ¿Qué películas son anteriores a los sesenta? Generar un subconjunto de datos. .scrollable[ ```r datos.prev60 <- subset(imdb, Fecha < 1960) datos.prev60 ``` ``` ## Pelicula Fecha Nota Popularidad ## 5 12 hombres sin piedad 1957 8.9 748065 ## 19 Los siete samuráis 1954 8.6 334541 ## 24 ¡Qué bello es vivir! 1946 8.6 438390 ## 40 Tiempos modernos 1936 8.5 233246 ## 45 Luces de la ciudad 1931 8.5 179056 ## 49 Casablanca 1942 8.4 551891 ## 51 La ventana indiscreta 1954 8.4 473904 ## 57 El gran dictador 1940 8.4 216945 ## 60 Senderos de gloria 1957 8.4 190431 ## 61 El crepúsculo de los dioses 1950 8.4 214640 ## 64 Testigo de cargo 1957 8.4 119706 ## 93 Vértigo (De entre los muertos) 1958 8.3 389148 ## 94 M, el vampiro de Düsseldorf 1931 8.3 153172 ## 96 Ciudadano Kane 1941 8.3 428996 ## 98 Cantando bajo la lluvia 1952 8.3 233320 ## 99 Con la muerte en los talones 1959 8.3 317597 ## 101 Ikiru (Vivir) 1952 8.3 75365 ## 102 Ladrón de bicicletas 1948 8.3 158432 ## 104 El chico 1921 8.2 122576 ## 109 Perdición 1944 8.2 152262 ## 110 Metrópolis 1927 8.2 169424 ## 123 Pather Panchali (La canción del camino) 1955 8.2 30222 ## 132 Rashomon 1950 8.2 162959 ## 134 Eva al desnudo 1950 8.2 127915 ## 136 Con faldas y a lo loco 1959 8.2 258643 ## 147 El tesoro de Sierra Madre 1948 8.2 121571 ## 158 Crimen perfecto 1954 8.1 169820 ## 159 La quimera del oro 1925 8.1 108168 ## 163 El séptimo sello 1957 8.1 178832 ## 168 Fresas salvajes 1957 8.1 104051 ## 169 El tercer hombre 1949 8.1 167615 ## 175 El puente sobre el río Kwai 1957 8.1 214418 ## 180 Lo que el viento se llevó 1939 8.1 305980 ## 181 Cuentos de Tokio 1953 8.1 59131 ## 182 La ley del silencio 1954 8.1 150695 ## 189 El moderno Sherlock Holmes 1924 8.1 47308 ## 190 El maquinista de La General 1926 8.1 88400 ## 197 Caballero sin espada 1939 8.1 113047 ## 204 La pasión de Juana de Arco 1928 8.1 52536 ## 208 Ser o no ser 1942 8.1 35030 ## 212 Ben-Hur 1959 8.1 232048 ## 217 El salario del miedo 1953 8.1 59185 ## 227 Los cuatrocientos golpes 1959 8.0 113645 ## 231 Rebeca 1940 8.0 133188 ## 241 Sucedió una noche 1934 8.0 100609 ## 246 Las noches de Cabiria 1957 8.0 47356 ``` ] --- # 2. Ordenar el subconjunto de datos anterior según el año de lanzamiento. .scrollable[ ```r datos.prev60.ord <- datos.prev60[order(datos.prev60$Fecha),] datos.prev60.ord ``` ``` ## Pelicula Fecha Nota Popularidad ## 104 El chico 1921 8.2 122576 ## 189 El moderno Sherlock Holmes 1924 8.1 47308 ## 159 La quimera del oro 1925 8.1 108168 ## 190 El maquinista de La General 1926 8.1 88400 ## 110 Metrópolis 1927 8.2 169424 ## 204 La pasión de Juana de Arco 1928 8.1 52536 ## 45 Luces de la ciudad 1931 8.5 179056 ## 94 M, el vampiro de Düsseldorf 1931 8.3 153172 ## 241 Sucedió una noche 1934 8.0 100609 ## 40 Tiempos modernos 1936 8.5 233246 ## 180 Lo que el viento se llevó 1939 8.1 305980 ## 197 Caballero sin espada 1939 8.1 113047 ## 57 El gran dictador 1940 8.4 216945 ## 231 Rebeca 1940 8.0 133188 ## 96 Ciudadano Kane 1941 8.3 428996 ## 49 Casablanca 1942 8.4 551891 ## 208 Ser o no ser 1942 8.1 35030 ## 109 Perdición 1944 8.2 152262 ## 24 ¡Qué bello es vivir! 1946 8.6 438390 ## 102 Ladrón de bicicletas 1948 8.3 158432 ## 147 El tesoro de Sierra Madre 1948 8.2 121571 ## 169 El tercer hombre 1949 8.1 167615 ## 61 El crepúsculo de los dioses 1950 8.4 214640 ## 132 Rashomon 1950 8.2 162959 ## 134 Eva al desnudo 1950 8.2 127915 ## 98 Cantando bajo la lluvia 1952 8.3 233320 ## 101 Ikiru (Vivir) 1952 8.3 75365 ## 181 Cuentos de Tokio 1953 8.1 59131 ## 217 El salario del miedo 1953 8.1 59185 ## 19 Los siete samuráis 1954 8.6 334541 ## 51 La ventana indiscreta 1954 8.4 473904 ## 158 Crimen perfecto 1954 8.1 169820 ## 182 La ley del silencio 1954 8.1 150695 ## 123 Pather Panchali (La canción del camino) 1955 8.2 30222 ## 5 12 hombres sin piedad 1957 8.9 748065 ## 60 Senderos de gloria 1957 8.4 190431 ## 64 Testigo de cargo 1957 8.4 119706 ## 163 El séptimo sello 1957 8.1 178832 ## 168 Fresas salvajes 1957 8.1 104051 ## 175 El puente sobre el río Kwai 1957 8.1 214418 ## 246 Las noches de Cabiria 1957 8.0 47356 ## 93 Vértigo (De entre los muertos) 1958 8.3 389148 ## 99 Con la muerte en los talones 1959 8.3 317597 ## 136 Con faldas y a lo loco 1959 8.2 258643 ## 212 Ben-Hur 1959 8.1 232048 ## 227 Los cuatrocientos golpes 1959 8.0 113645 ``` ] --- # 3.1 Hacer un diagrama de barras cuya altura es la popularidad de cada película. ```r barplot(datos.prev60.ord$Popularidad, main = "Popularidad", las = 2, cex.axis = 0.8) ``` <img src="Slides_files/figure-html/unnamed-chunk-55-1.png" style="display: block; margin: auto;" /> --- # 3.2 Indicar el título y el año de lanzamiento. ```r *etiqueta.peli <- paste0(datos.prev60.ord$Pelicula, * " (", datos.prev60.ord$Fecha, ")") barplot(datos.prev60.ord$Popularidad, main = "Popularidad", * names.arg = etiqueta.peli, cex.names = 0.7, las = 2, cex.axis = 0.8) ``` <img src="Slides_files/figure-html/unnamed-chunk-56-1.png" style="display: block; margin: auto;" /> --- # 3.2 Indicar el título y el año de lanzamiento. ```r etiqueta.peli <- paste0(datos.prev60.ord$Pelicula, " (", datos.prev60.ord$Fecha, ")") barplot(datos.prev60.ord$Popularidad, main = "Popularidad", names.arg = etiqueta.peli, cex.names = 0.7, las = 2, cex.axis = 0.8, * horiz = TRUE) ``` <img src="Slides_files/figure-html/unnamed-chunk-57-1.png" style="display: block; margin: auto;" /> --- # 3.2 Indicar el título y el año de lanzamiento. ```r etiqueta.peli <- paste0(datos.prev60.ord$Pelicula, " (", datos.prev60.ord$Fecha, ")") *par(mar = c(5.1,11.5,4.1,2.1)) barplot(datos.prev60.ord$Popularidad, main = "Popularidad", names.arg = etiqueta.peli, cex.names = 0.7, las = 2, cex.axis = 0.8, horiz = TRUE) ``` <img src="Slides_files/figure-html/unnamed-chunk-58-1.png" style="display: block; margin: auto;" /> --- # 3.2 Indicar el título y el año de lanzamiento. ```r *graph.datos <- datos.prev60.ord[nrow(datos.prev60.ord):1,] etiqueta.peli <- paste0(graph.datos$Pelicula, " (", graph.datos$Fecha, ")") par(mar = c(5.1,11.5,4.1,2.1)) barplot(graph.datos$Popularidad, main = "Popularidad", names.arg = etiqueta.peli, cex.names = 0.7, las = 2, cex.axis = 0.8, horiz = TRUE) ``` <img src="Slides_files/figure-html/unnamed-chunk-59-1.png" style="display: block; margin: auto;" /> --- # 3.3 Colorear las barras según la popularidad. ```r par(mar = c(5.1,11.5,4.1,2.1)) barplot(graph.datos$Popularidad, main = "Popularidad", * col = ifelse(graph.datos$Popularidad > 300000, 'red', * ifelse(graph.datos$Popularidad > 100000, 'orange', 'yellow')), names.arg = etiqueta.peli, cex.names = 0.7, las = 2, cex.axis = 0.8, horiz = TRUE) ``` <img src="Slides_files/figure-html/unnamed-chunk-60-1.png" style="display: block; margin: auto;" /> --- # 3.3 Colorear las barras según la popularidad. ```r par(mar = c(5.1,11.5,4.1,2.1)) barplot(graph.datos$Popularidad, main = "Popularidad", col = ifelse(graph.datos$Popularidad > 300000, 'red', ifelse(graph.datos$Popularidad > 100000, 'orange', 'yellow')), names.arg = etiqueta.peli, cex.names = 0.7, las = 2, cex.axis = 0.8, horiz = TRUE) *legend('topright', c("<= 100000", "100000 - 30000", "> 300000"), * col = c("yellow", "orange", "red"), lwd = 5, bty = "n") ``` <img src="Slides_files/figure-html/unnamed-chunk-61-1.png" style="display: block; margin: auto;" /> --- # 4. Guardarlo en un PDF con anchura 7 inches (por defecto) y altura 8 inches. ```r *pdf("Popularidad_Peliculas_antes60.pdf", height = 8) par(mar = c(5.1,11.5,4.1,2.1)) barplot(graph.datos$Popularidad, main = "Popularidad", col = ifelse(graph.datos$Popularidad > 300000, 'red', ifelse(graph.datos$Popularidad > 100000, 'orange', 'yellow')), names.arg = etiqueta.peli, cex.names = 0.7, las = 2, cex.axis = 0.8, horiz = TRUE) legend('topright', c("<= 100000", "100000 - 30000", "> 300000"), col = c("yellow", "orange", "red"), lwd = 5, bty = "n") *dev.off() ``` -- <br> .center[.content-box-purple[¿Dónde ha guardado el PDF?]] -- <br> .center[.content-box-purple[¿Cómo cambiar el directorio en R?]] --- class: center, middle background-color: rosybrown # Hacer un gráfico con las películas lanzadas cada año, ordenadas de más antigua a más moderna, indicando la nota de cada una. Añadir todos los años en el rango ## Gráfico Peliculas_top250_cronologico.pdf --- # Gráfico Peliculas_top250_cronologico.pdf -- 1. Ordenar las 250 películas según el año de lanzamiento, de más reciente a más antigua (*). .footnote[(*) Porque el diagrama de barras horizontal ordena de abajo a arriba por defecto.] -- 2. Crear una nueva variable que indique el color según el rango de nota con puntos de corte con salto `\(0.25\)` desde `\(8\)` (nota mínima) en adelante. -- 3. Crear una tabla que indique el número de películas registradas por año. En dicha tabla, añadir los años sin películas registradas con frecuencia `\(0\)`. -- 4. Construir el gráfico: -- * un diagrama de barras cuya altura es `\(1\)` si hay películas ese año y `\(0\)` en caso contrario y cuya anchura es el número de películas `\(+1\)`; -- * indicar el título y la nota de cada película en su año correspondiente; -- * colorear los nombres de las películas según su rango de puntuación. -- 5. Guardarlo en un PDF con anchura 7 inches (p. defecto) y altura 45 inches. --- # 1. Ordenar las 250 películas según el año de lanzamiento, de más reciente a más antigua. .scrollable[ ```r imdb.ordporfecha <- imdb[order(imdb$Fecha, decreasing = TRUE),] imdb.ordporfecha ``` ``` ## Pelicula Fecha Nota Popularidad ## 21 Spider-Man: No Way Home 2021 8.6 412230 ## 140 Jai Bhim 2021 8.2 170266 ## 196 Dune 2021 8.1 458099 ## 87 Hamilton 2020 8.3 81385 ## 111 El padre 2020 8.2 120085 ## 244 Guardianes de la noche - Kimetsu no Yaiba - La película: Tren Infinito 2020 8.0 44604 ## 31 Parásitos 2019 8.5 709314 ## 70 Joker 2019 8.3 1132183 ## 76 Vengadores: Endgame 2019 8.3 1000782 ## 118 1917 2019 8.2 526049 ## 157 Klaus 2019 8.1 136932 ## 206 Le Mans '66 2019 8.1 352169 ## 63 Vengadores: Infinity War 2018 8.4 972106 ## 65 Spider-Man: Un nuevo universo 2018 8.4 464284 ## 77 Cafarnaúm 2018 8.3 80736 ## 131 Green Book 2018 8.2 446422 ## 205 Andhadhun 2018 8.1 86658 ## 72 Coco 2017 8.3 456615 ## 161 Tres anuncios en las afueras 2017 8.1 479400 ## 221 Logan 2017 8.1 709327 ## 71 Your Name. 2016 8.3 238093 ## 107 Dangal 2016 8.2 177104 ## 201 Hasta el último hombre 2016 8.1 485826 ## 219 La doncella 2016 8.1 133575 ## 223 A Silent Voice 2016 8.0 69898 ## 176 Del revés (Inside Out) 2015 8.1 671630 ## 203 La habitación 2015 8.1 401307 ## 214 Mad Max: Furia en la carretera 2015 8.1 949615 ## 229 Spotlight 2015 8.0 451856 ## 28 Interstellar 2014 8.5 1677437 ## 43 Whiplash 2014 8.5 786708 ## 184 Relatos salvajes 2014 8.1 190480 ## 187 El gran hotel Budapest 2014 8.1 765477 ## 202 Perdida 2014 8.1 931890 ## 142 El lobo de Wall Street 2013 8.2 1306036 ## 185 Prisioneros 2013 8.1 659583 ## 207 12 años de esclavitud 2013 8.1 675770 ## 236 Rush 2013 8.0 461379 ## 247 Drishyam 2013 8.0 39258 ## 58 Django desencadenado 2012 8.4 1463753 ## 73 El caballero oscuro: La leyenda renace 2012 8.3 1610958 ## 95 La caza 2012 8.3 312416 ## 226 Gangs of Wasseypur 2012 8.0 92115 ## 47 Intocable 2011 8.5 815790 ## 112 Nader y Simin, una separación 2011 8.2 236017 ## 179 Warrior 2011 8.1 456604 ## 211 Harry Potter y las Reliquias de la Muerte - Parte 2 2011 8.1 827499 ## 13 Origen 2010 8.7 2224763 ## 106 Incendios 2010 8.2 167993 ## 121 Toy Story 3 2010 8.2 800434 ## 154 Shutter Island 2010 8.1 1229831 ## 213 Cómo entrenar a tu dragón 2010 8.1 706987 ## 80 3 Idiots 2009 8.3 376773 ## 85 Malditos bastardos 2009 8.3 1365916 ## 124 Up 2009 8.2 995872 ## 150 El secreto de sus ojos 2009 8.1 203930 ## 194 Mary and Max 2009 8.1 172961 ## 225 Siempre a tu lado (Hachiko) 2009 8.0 272353 ## 4 El caballero oscuro 2008 9.0 2482152 ## 62 WALL·E 2008 8.4 1064290 ## 191 Gran Torino 2008 8.1 752740 ## 92 Taare Zameen Par 2007 8.3 184733 ## 144 Pozos de ambición 2007 8.2 557919 ## 156 No es país para viejos 2007 8.1 923113 ## 239 Hacia rutas salvajes 2007 8.0 604187 ## 46 Infiltrados 2006 8.5 1265213 ## 48 El truco final (El prestigio) 2006 8.5 1271569 ## 59 La vida de los otros 2006 8.4 378535 ## 148 El laberinto del fauno 2006 8.1 647987 ## 137 Batman Begins 2005 8.2 1387187 ## 171 V de Vendetta 2005 8.1 1084856 ## 183 Mi padre y mi hijo 2005 8.1 84450 ## 100 ¡Olvídate de mí! 2004 8.3 965057 ## 133 El hundimiento 2004 8.2 346121 ## 141 El castillo ambulante 2004 8.2 368982 ## 216 Million Dollar Baby 2004 8.1 666918 ## 234 Hotel Rwanda 2004 8.0 347572 ## 242 Antes del atardecer 2004 8.0 252785 ## 7 El señor de los anillos: El retorno del rey 2003 8.9 1747018 ## 69 Old Boy 2003 8.3 552568 ## 170 Memories of Murder (Crónica de un asesino en serie) 2003 8.1 166412 ## 177 Buscando a Nemo 2003 8.1 1001551 ## 178 Kill Bill: Volumen 1 2003 8.1 1066850 ## 14 El señor de los anillos: Las dos torres 2002 8.7 1578445 ## 23 Ciudad de Dios 2002 8.6 732467 ## 34 El pianista 2002 8.5 789182 ## 195 Atrápame si puedes 2002 8.1 915229 ## 10 El señor de los anillos: La comunidad del anillo 2001 8.8 1768396 ## 29 El viaje de Chihiro 2001 8.5 714107 ## 119 Amelie 2001 8.2 734458 ## 149 Una mente maravillosa 2001 8.1 896776 ## 230 Monstruos, S.A. 2001 8.0 867959 ## 44 Gladiator (El gladiador) 2000 8.5 1429325 ## 55 Memento 2000 8.4 1189688 ## 97 Réquiem por un sueño 2000 8.3 808322 ## 117 Snatch, cerdos y diamantes 2000 8.2 825488 ## 233 Deseando amar 2000 8.0 141435 ## 238 Amores perros 2000 8.0 234975 ## 11 El club de la lucha 1999 8.7 1991339 ## 16 Matrix 1999 8.7 1826876 ## 30 La milla verde 1999 8.5 1231748 ## 83 American Beauty 1999 8.3 1119463 ## 165 El sexto sentido 1999 8.1 956122 ## 26 Salvar al soldado Ryan 1998 8.6 1321592 ## 42 American History X 1998 8.5 1082985 ## 155 Lock & Stock 1998 8.1 564096 ## 166 El show de Truman 1998 8.1 1013743 ## 209 El gran Lebowski 1998 8.1 779517 ## 25 La vida es bella 1997 8.6 665547 ## 68 La princesa Mononoke 1997 8.3 373966 ## 86 El indomable Will Hunting 1997 8.3 920815 ## 127 L.A. Confidential 1997 8.2 563055 ## 139 Children of Heaven 1997 8.2 71970 ## 249 Neon Genesis Evangelion: The End of Evangelion 1997 8.0 50007 ## 173 Trainspotting 1996 8.1 665554 ## 174 Fargo 1996 8.1 654580 ## 235 Eskiya 1996 8.0 68886 ## 20 Seven 1995 8.6 1553428 ## 37 Sospechosos habituales 1995 8.5 1046304 ## 81 Toy Story 1995 8.3 946338 ## 84 Braveheart 1995 8.3 1003644 ## 126 Heat 1995 8.2 622555 ## 146 Casino 1995 8.2 497705 ## 193 Antes de amanecer 1995 8.1 293003 ## 222 El odio 1995 8.1 164354 ## 1 Cadena perpetua 1994 9.2 2531700 ## 8 Pulp Fiction 1994 8.8 1949998 ## 12 Forrest Gump 1994 8.7 1953976 ## 32 El profesional (Léon) 1994 8.5 1106314 ## 39 El rey león 1994 8.5 1005098 ## 6 La lista de Schindler 1993 8.9 1293509 ## 167 Jurassic Park (Parque Jurásico) 1993 8.1 928473 ## 200 En el nombre del padre 1993 8.1 168789 ## 91 Reservoir Dogs 1992 8.3 975499 ## 138 Sin perdón 1992 8.2 398401 ## 22 El silencio de los corderos 1991 8.6 1361143 ## 35 Terminator 2: El juicio final 1991 8.5 1052376 ## 17 Uno de los nuestros 1990 8.6 1095102 ## 125 Indiana Jones y la última cruzada 1989 8.2 728829 ## 210 El club de los poetas muertos 1989 8.1 461065 ## 41 La tumba de las luciérnagas 1988 8.5 259944 ## 52 Cinema Paradiso 1988 8.4 250455 ## 130 Jungla de cristal 1988 8.2 846514 ## 153 Mi vecino Totoro 1988 8.1 319764 ## 105 La chaqueta metálica 1987 8.2 713333 ## 250 La princesa prometida 1987 8.0 416514 ## 74 Aliens: El regreso 1986 8.3 690362 ## 218 Cuenta conmigo 1986 8.1 386516 ## 228 Platoon 1986 8.0 401189 ## 36 Regreso al futuro 1985 8.5 1138876 ## 89 Masacre (Ven y mira) 1985 8.3 71458 ## 128 Ran 1985 8.2 121545 ## 75 Érase una vez en América 1984 8.3 336927 ## 82 Amadeus 1984 8.3 388247 ## 240 Nausicaä del Valle del Viento 1984 8.0 163587 ## 88 El retorno del jedi 1983 8.3 1004735 ## 116 El precio del poder 1983 8.2 795535 ## 160 La cosa 1982 8.1 402183 ## 172 Blade Runner 1982 8.1 737437 ## 243 Fanny y Alexander 1982 8.0 62391 ## 56 En busca del arca perdida 1981 8.4 931623 ## 78 El submarino (Das Boot) 1981 8.3 244173 ## 15 El Imperio contraataca 1980 8.7 1229090 ## 66 El resplandor 1980 8.4 966871 ## 151 Toro salvaje 1980 8.1 341110 ## 164 El hombre elefante 1980 8.1 233936 ## 53 Alien, el octavo pasajero 1979 8.4 840139 ## 54 Apocalypse Now 1979 8.4 641438 ## 186 Stalker 1979 8.1 129292 ## 232 La vida de Brian 1979 8.0 387727 ## 188 El cazador 1978 8.1 329409 ## 215 Sonata de otoño 1978 8.1 32801 ## 27 La guerra de las galaxias 1977 8.5 1300609 ## 113 Taxi Driver 1976 8.2 779371 ## 220 Network, un mundo implacable 1976 8.1 154555 ## 237 Rocky 1976 8.0 550599 ## 18 Alguien voló sobre el nido del cuco 1975 8.6 969761 ## 135 Los caballeros de la mesa cuadrada y sus locos seguidores 1975 8.2 525254 ## 162 Dersu Uzala (El cazador) 1975 8.1 26968 ## 198 Barry Lyndon 1975 8.1 161449 ## 3 El padrino: Parte II 1974 9.0 1209198 ## 152 Chinatown 1974 8.1 314754 ## 115 El golpe 1973 8.2 254194 ## 2 El padrino 1972 9.1 1742891 ## 114 La naranja mecánica 1971 8.2 798908 ## 199 Z 1969 8.1 27237 ## 50 Hasta que llegó su hora 1968 8.4 319396 ## 90 2001: Una odisea del espacio 1968 8.3 641827 ## 224 La leyenda del indomable 1967 8.0 172452 ## 9 El bueno, el feo y el malo 1966 8.8 731614 ## 192 Persona 1966 8.1 113323 ## 245 La batalla de Argel 1966 8.0 58041 ## 248 Andrei Rublev 1966 8.0 52044 ## 122 La muerte tenía un precio 1965 8.2 247853 ## 67 ¿Teléfono rojo? Volamos hacia Moscú 1964 8.4 474230 ## 79 El infierno del odio 1963 8.3 41343 ## 145 La gran evasión 1963 8.2 237665 ## 33 Harakiri 1962 8.5 51721 ## 103 Lawrence de Arabia 1962 8.3 284236 ## 120 Matar a un ruiseñor 1962 8.2 308205 ## 129 Yojimbo 1961 8.2 119191 ## 143 Vencedores o vencidos 1961 8.2 74989 ## 38 Psicosis 1960 8.5 643322 ## 108 El apartamento 1960 8.2 175448 ## 99 Con la muerte en los talones 1959 8.3 317597 ## 136 Con faldas y a lo loco 1959 8.2 258643 ## 212 Ben-Hur 1959 8.1 232048 ## 227 Los cuatrocientos golpes 1959 8.0 113645 ## 93 Vértigo (De entre los muertos) 1958 8.3 389148 ## 5 12 hombres sin piedad 1957 8.9 748065 ## 60 Senderos de gloria 1957 8.4 190431 ## 64 Testigo de cargo 1957 8.4 119706 ## 163 El séptimo sello 1957 8.1 178832 ## 168 Fresas salvajes 1957 8.1 104051 ## 175 El puente sobre el río Kwai 1957 8.1 214418 ## 246 Las noches de Cabiria 1957 8.0 47356 ## 123 Pather Panchali (La canción del camino) 1955 8.2 30222 ## 19 Los siete samuráis 1954 8.6 334541 ## 51 La ventana indiscreta 1954 8.4 473904 ## 158 Crimen perfecto 1954 8.1 169820 ## 182 La ley del silencio 1954 8.1 150695 ## 181 Cuentos de Tokio 1953 8.1 59131 ## 217 El salario del miedo 1953 8.1 59185 ## 98 Cantando bajo la lluvia 1952 8.3 233320 ## 101 Ikiru (Vivir) 1952 8.3 75365 ## 61 El crepúsculo de los dioses 1950 8.4 214640 ## 132 Rashomon 1950 8.2 162959 ## 134 Eva al desnudo 1950 8.2 127915 ## 169 El tercer hombre 1949 8.1 167615 ## 102 Ladrón de bicicletas 1948 8.3 158432 ## 147 El tesoro de Sierra Madre 1948 8.2 121571 ## 24 ¡Qué bello es vivir! 1946 8.6 438390 ## 109 Perdición 1944 8.2 152262 ## 49 Casablanca 1942 8.4 551891 ## 208 Ser o no ser 1942 8.1 35030 ## 96 Ciudadano Kane 1941 8.3 428996 ## 57 El gran dictador 1940 8.4 216945 ## 231 Rebeca 1940 8.0 133188 ## 180 Lo que el viento se llevó 1939 8.1 305980 ## 197 Caballero sin espada 1939 8.1 113047 ## 40 Tiempos modernos 1936 8.5 233246 ## 241 Sucedió una noche 1934 8.0 100609 ## 45 Luces de la ciudad 1931 8.5 179056 ## 94 M, el vampiro de Düsseldorf 1931 8.3 153172 ## 204 La pasión de Juana de Arco 1928 8.1 52536 ## 110 Metrópolis 1927 8.2 169424 ## 190 El maquinista de La General 1926 8.1 88400 ## 159 La quimera del oro 1925 8.1 108168 ## 189 El moderno Sherlock Holmes 1924 8.1 47308 ## 104 El chico 1921 8.2 122576 ``` ] --- # NOTA: En esta presentación, con fines ilustrativos, se consideran solamente las películas desde el año 1966 al 1972. ```r imdb.ordporfecha <- subset(imdb.ordporfecha, Fecha >= 1966 & Fecha <= 1972) imdb.ordporfecha ``` ``` ## Pelicula Fecha Nota Popularidad ## 2 El padrino 1972 9.1 1742891 ## 114 La naranja mecánica 1971 8.2 798908 ## 199 Z 1969 8.1 27237 ## 50 Hasta que llegó su hora 1968 8.4 319396 ## 90 2001: Una odisea del espacio 1968 8.3 641827 ## 224 La leyenda del indomable 1967 8.0 172452 ## 9 El bueno, el feo y el malo 1966 8.8 731614 ## 192 Persona 1966 8.1 113323 ## 245 La batalla de Argel 1966 8.0 58041 ## 248 Andrei Rublev 1966 8.0 52044 ``` --- # 2. Crear una nueva variable que indique el color según el rango de nota. ```r imdb.ordporfecha$NotaGrupo <- cut(imdb.ordporfecha$Nota, breaks = c(8,8.25,8.5,8.75,9,9.25), include.lowest = TRUE) imdb.ordporfecha ``` ``` ## Pelicula Fecha Nota Popularidad NotaGrupo ## 2 El padrino 1972 9.1 1742891 (9,9.25] ## 114 La naranja mecánica 1971 8.2 798908 [8,8.25] ## 199 Z 1969 8.1 27237 [8,8.25] ## 50 Hasta que llegó su hora 1968 8.4 319396 (8.25,8.5] ## 90 2001: Una odisea del espacio 1968 8.3 641827 (8.25,8.5] ## 224 La leyenda del indomable 1967 8.0 172452 [8,8.25] ## 9 El bueno, el feo y el malo 1966 8.8 731614 (8.75,9] ## 192 Persona 1966 8.1 113323 [8,8.25] ## 245 La batalla de Argel 1966 8.0 58041 [8,8.25] ## 248 Andrei Rublev 1966 8.0 52044 [8,8.25] ``` --- # 2. Crear una nueva variable que indique el color según el rango de nota. ```r library(RColorBrewer) imdb.ordporfecha$ColorNota <- imdb.ordporfecha$NotaGrupo levels(imdb.ordporfecha$ColorNota) <- brewer.pal(9, "YlOrRd")[5:9] imdb.ordporfecha$ColorNota <- as.character(imdb.ordporfecha$ColorNota) imdb.ordporfecha ``` ``` ## Pelicula Fecha Nota Popularidad NotaGrupo ColorNota ## 2 El padrino 1972 9.1 1742891 (9,9.25] #800026 ## 114 La naranja mecánica 1971 8.2 798908 [8,8.25] #FD8D3C ## 199 Z 1969 8.1 27237 [8,8.25] #FD8D3C ## 50 Hasta que llegó su hora 1968 8.4 319396 (8.25,8.5] #FC4E2A ## 90 2001: Una odisea del espacio 1968 8.3 641827 (8.25,8.5] #FC4E2A ## 224 La leyenda del indomable 1967 8.0 172452 [8,8.25] #FD8D3C ## 9 El bueno, el feo y el malo 1966 8.8 731614 (8.75,9] #BD0026 ## 192 Persona 1966 8.1 113323 [8,8.25] #FD8D3C ## 245 La batalla de Argel 1966 8.0 58041 [8,8.25] #FD8D3C ## 248 Andrei Rublev 1966 8.0 52044 [8,8.25] #FD8D3C ``` --- # 3. Crear una tabla que indique el número de películas registradas por año. ```r frec.fechas <- table(imdb.ordporfecha$Fecha) frec.fechas ``` ``` ## ## 1966 1967 1968 1969 1971 1972 ## 4 1 2 1 1 1 ``` --- # 3. En dicha tabla, añadir los años sin películas registradas con frecuencia 0 (A) ```r every.year <- max(imdb.ordporfecha$Fecha):min(imdb.ordporfecha$Fecha) frec.every.year <- NULL for(year in every.year){ if(year %in% names(frec.fechas)){ frec.every.year <- c(frec.every.year, frec.fechas[as.character(year)]) }else{ frec.every.year <- c(frec.every.year, 0) names(frec.every.year)[length(frec.every.year)] <- year } } frec.every.year ``` ``` ## 1972 1971 1970 1969 1968 1967 1966 ## 1 1 0 1 2 1 4 ``` --- # 3. En dicha tabla, añadir los años sin películas registradas con frecuencia 0 (B) ```r frec.every.year <- table(factor(imdb.ordporfecha$Fecha, levels = max(imdb.ordporfecha$Fecha):min(imdb.ordporfecha$Fecha))) frec.every.year ``` ``` ## ## 1972 1971 1970 1969 1968 1967 1966 ## 1 1 0 1 2 1 4 ``` --- # 3. En dicha tabla, añadir los años sin películas registradas con frecuencia 0 (C) ```r every.year <- imdb.ordporfecha$Fecha %>% range() %>% as.list() %>% do.call(what = seq) every.year ``` ``` ## [1] 1966 1967 1968 1969 1970 1971 1972 ``` ```r aux <- frec.fechas[as.character(every.year)] aux ``` ``` ## ## 1966 1967 1968 1969 <NA> 1971 1972 ## 4 1 2 1 1 1 ``` --- # 3. En dicha tabla, añadir los años sin películas registradas con frecuencia 0 (C) ```r ifelse(is.na(aux), 0, aux) ``` ``` ## ## 1966 1967 1968 1969 <NA> 1971 1972 ## 4 1 2 1 0 1 1 ``` ```r frec.every.year <- rev(setNames(ifelse(is.na(aux), 0, aux), every.year)) frec.every.year ``` ``` ## 1972 1971 1970 1969 1968 1967 1966 ## 1 1 0 1 2 1 4 ``` --- class: center, middle background-color: rosybrown # 4.1 Crear un diagrama de barras cuya altura es 1 si hay películas ese año y 0 en caso contrario y cuya anchura es n.pelis +1. --- ```r espacio <- 0.5 barplot(height = ifelse(frec.every.year == 0, 0, 1), width = frec.every.year + 1, ylim = c(0,10), las = 2, axes = FALSE, space = espacio) ``` <img src="Slides_files/figure-html/unnamed-chunk-72-1.png" style="display: block; margin: auto;" /> --- ```r espacio <- 0.5 barplot(height = ifelse(frec.every.year == 0, 0, 1), width = frec.every.year + 1, * horiz = TRUE, xlim = c(0,10), cex.names = 0.7, las = 2, axes = FALSE, space = espacio) ``` <img src="Slides_files/figure-html/unnamed-chunk-73-1.png" style="display: block; margin: auto;" /> --- ## ¿Cuáles son las coordenadas utilizadas por barplot()? ```r espacio <- 0.5 opt.barplot <- barplot(height = ifelse(frec.every.year == 0, 0, 1), width = frec.every.year + 1, horiz = TRUE, xlim = c(0,10), cex.names = 0.7, las = 2, axes = FALSE, space = espacio) ``` ```r opt.barplot ``` ``` ## [,1] ## [1,] 2.214286 ## [2,] 5.428571 ## [3,] 8.142857 ## [4,] 10.857143 ## [5,] 14.571429 ## [6,] 18.285714 ## [7,] 23.000000 ``` -- .center[.content-box-purple[No parecen ser las coordenadas "naturales"...]] --- ## ¿Cómo funciona el comando barplot()? .scrollable[ ```r methods(barplot) ``` ``` ## [1] barplot.default barplot.formula* ## see '?methods' for accessing help and source code ``` ```r barplot.default ``` ``` ## function (height, width = 1, space = NULL, names.arg = NULL, ## legend.text = NULL, beside = FALSE, horiz = FALSE, density = NULL, ## angle = 45, col = NULL, border = par("fg"), main = NULL, ## sub = NULL, xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, ## xpd = TRUE, log = "", axes = TRUE, axisnames = TRUE, cex.axis = par("cex.axis"), ## cex.names = par("cex.axis"), inside = TRUE, plot = TRUE, ## axis.lty = 0, offset = 0, add = FALSE, ann = !add && par("ann"), ## args.legend = NULL, ...) ## { ## if (!missing(inside)) ## .NotYetUsed("inside", error = FALSE) ## if (is.null(space)) ## space <- if (is.matrix(height) && beside) ## c(0, 1) ## else 0.2 ## space <- space * mean(width) ## if (plot && axisnames && is.null(names.arg)) ## names.arg <- if (is.matrix(height)) ## colnames(height) ## else names(height) ## vectorInput <- (is.vector(height) || (is.array(height) && ## (length(dim(height)) == 1))) ## if (vectorInput) { ## height <- cbind(height) ## beside <- TRUE ## if (is.null(col)) ## col <- "grey" ## } ## else if (is.matrix(height)) { ## if (is.null(col)) ## col <- gray.colors(nrow(height)) ## } ## else stop("'height' must be a vector or a matrix") ## if (is.logical(legend.text)) ## legend.text <- if (legend.text && is.matrix(height)) ## rownames(height) ## stopifnot(is.character(log)) ## logx <- logy <- FALSE ## if (log != "") { ## logx <- length(grep("x", log)) > 0L ## logy <- length(grep("y", log)) > 0L ## } ## if ((logx || logy) && !is.null(density)) ## stop("Cannot use shading lines in bars when log scale is used") ## NR <- nrow(height) ## NC <- ncol(height) ## if (beside) { ## if (length(space) == 2 && !vectorInput) ## space <- rep.int(c(space[2L], rep.int(space[1L], ## NR - 1)), NC) ## width <- rep_len(width, NR) ## } ## else { ## width <- rep_len(width, NC) ## } ## offset <- rep_len(as.vector(offset), length(width)) ## delta <- width/2 ## w.r <- cumsum(space + width) ## w.m <- w.r - delta ## w.l <- w.m - delta ## log.dat <- (logx && horiz) || (logy && !horiz) ## if (log.dat) { ## if (min(height + offset, na.rm = TRUE) <= 0) ## stop("log scale error: at least one 'height + offset' value <= 0") ## if (logx && !is.null(xlim) && min(xlim) <= 0) ## stop("log scale error: 'xlim' <= 0") ## if (logy && !is.null(ylim) && min(ylim) <= 0) ## stop("log scale error: 'ylim' <= 0") ## rectbase <- if (logy && !horiz && !is.null(ylim)) ## ylim[1L] ## else if (logx && horiz && !is.null(xlim)) ## xlim[1L] ## else 0.9 * min(height, na.rm = TRUE) ## } ## else rectbase <- 0 ## if (!beside) ## height <- rbind(rectbase, apply(height, 2L, cumsum)) ## rAdj <- offset + (if (log.dat) ## 0.9 * height ## else -0.01 * height) ## delta <- width/2 ## w.r <- cumsum(space + width) ## w.m <- w.r - delta ## w.l <- w.m - delta ## if (horiz) { ## if (is.null(xlim)) ## xlim <- range(rAdj, height + offset, na.rm = TRUE) ## if (is.null(ylim)) ## ylim <- c(min(w.l), max(w.r)) ## } ## else { ## if (is.null(xlim)) ## xlim <- c(min(w.l), max(w.r)) ## if (is.null(ylim)) ## ylim <- range(rAdj, height + offset, na.rm = TRUE) ## } ## if (beside) ## w.m <- matrix(w.m, ncol = NC) ## if (plot) { ## dev.hold() ## opar <- if (horiz) ## par(xaxs = "i", xpd = xpd) ## else par(yaxs = "i", xpd = xpd) ## on.exit({ ## dev.flush() ## par(opar) ## }) ## if (!add) { ## plot.new() ## plot.window(xlim, ylim, log = log, ...) ## } ## xyrect <- function(x1, y1, x2, y2, horizontal = TRUE, ## ...) { ## if (horizontal) ## rect(x1, y1, x2, y2, ...) ## else rect(y1, x1, y2, x2, ...) ## } ## if (beside) ## xyrect(rectbase + offset, w.l, c(height) + offset, ## w.r, horizontal = horiz, angle = angle, density = density, ## col = col, border = border) ## else { ## for (i in 1L:NC) { ## xyrect(height[1L:NR, i] + offset[i], w.l[i], ## height[-1, i] + offset[i], w.r[i], horizontal = horiz, ## angle = angle, density = density, col = col, ## border = border) ## } ## } ## if (axisnames && !is.null(names.arg)) { ## at.l <- if (length(names.arg) != length(w.m)) { ## if (length(names.arg) == NC) ## colMeans(w.m) ## else stop("incorrect number of names") ## } ## else w.m ## axis(if (horiz) ## 2 ## else 1, at = at.l, labels = names.arg, lty = axis.lty, ## cex.axis = cex.names, ...) ## } ## if (!is.null(legend.text)) { ## legend.col <- rep_len(col, length(legend.text)) ## if ((horiz & beside) || (!horiz & !beside)) { ## legend.text <- rev(legend.text) ## legend.col <- rev(legend.col) ## density <- rev(density) ## angle <- rev(angle) ## } ## xy <- par("usr") ## if (is.null(args.legend)) { ## legend(xy[2L] - xinch(0.1), xy[4L] - yinch(0.1), ## legend = legend.text, angle = angle, density = density, ## fill = legend.col, xjust = 1, yjust = 1) ## } ## else { ## args.legend1 <- list(x = xy[2L] - xinch(0.1), ## y = xy[4L] - yinch(0.1), legend = legend.text, ## angle = angle, density = density, fill = legend.col, ## xjust = 1, yjust = 1) ## args.legend1[names(args.legend)] <- args.legend ## do.call("legend", args.legend1) ## } ## } ## if (ann) ## title(main = main, sub = sub, xlab = xlab, ylab = ylab, ## ...) ## if (axes) ## axis(if (horiz) ## 1 ## else 2, cex.axis = cex.axis, ...) ## invisible(w.m) ## } ## else w.m ## } ## <bytecode: 0x7f8e62751648> ## <environment: namespace:graphics> ``` ] --- ## ¿Cuáles son las coordenadas utilizadas por barplot() cambiando el argumento space? ```r espacio <- 0.5 opt.barplot <- barplot(height = ifelse(frec.every.year == 0, 0, 1), width = frec.every.year + 1, horiz = TRUE, xlim = c(0,10), cex.names = 0.7, las = 2, axes = FALSE, space = espacio/mean(frec.every.year + 1)) ``` ```r opt.barplot ``` ``` ## [,1] ## [1,] 1.5 ## [2,] 4.0 ## [3,] 6.0 ## [4,] 8.0 ## [5,] 11.0 ## [6,] 14.0 ## [7,] 18.0 ``` --- ## ¿Cómo obtener las coordenadas de los límites de las barras? ```r espacio ``` ``` ## [1] 0.5 ``` ```r frec.every.year + 1 ``` ``` ## 1972 1971 1970 1969 1968 1967 1966 ## 2 2 1 2 3 2 5 ``` ```r ptos.finales <- cumsum(frec.every.year + 1) + espacio*(1:length(frec.every.year)) ptos.iniciales <- c(espacio, ptos.finales[-length(ptos.finales)] + espacio) ``` --- ## ¿Cómo obtener las coordenadas de los límites de las barras? ```r tabla.pos <- cbind(ptos.iniciales, ptos.finales, frec.every.year) rownames(tabla.pos) <- names(frec.every.year) tabla.pos ``` ``` ## ptos.iniciales ptos.finales frec.every.year ## 1972 0.5 2.5 1 ## 1971 3.0 5.0 1 ## 1970 5.5 6.5 0 ## 1969 7.0 9.0 1 ## 1968 9.5 12.5 2 ## 1967 13.0 15.0 1 ## 1966 15.5 20.5 4 ``` --- ## Comprobar que las coordenadas son correctas. ```r espacio <- 0.5 opt.barplot <- barplot(height = ifelse(frec.every.year == 0, 0, 1), width = frec.every.year + 1, horiz = TRUE, xlim = c(0,10), cex.names = 0.7, las = 2, axes = FALSE, space = espacio/mean(frec.every.year + 1)) *points(rep(1.15, length(ptos.iniciales)), ptos.iniciales, pch = "-", col = 'green') *points(rep(1.15, length(ptos.finales)), ptos.finales, pch = "-", col = 'red') ``` <img src="Slides_files/figure-html/unnamed-chunk-81-1.png" style="display: block; margin: auto;" /> --- ## Recordar tabla.pos. ```r tabla.pos ``` ``` ## ptos.iniciales ptos.finales frec.every.year ## 1972 0.5 2.5 1 ## 1971 3.0 5.0 1 ## 1970 5.5 6.5 0 ## 1969 7.0 9.0 1 ## 1968 9.5 12.5 2 ## 1967 13.0 15.0 1 ## 1966 15.5 20.5 4 ``` --- ## Crear los items para cada película en su año. ```r for(year in rownames(tabla.pos)){ n.frec <- tabla.pos[year,3] if(n.frec > 0){ y.pos <- seq(tabla.pos[year,1], tabla.pos[year,2], length.out = n.frec+2)[2:(n.frec+1)] points(rep(1.15, n.frec), y.pos, pch = "-") } } ``` <img src="Slides_files/figure-html/unnamed-chunk-84-1.png" style="display: block; margin: auto;" /> --- class: center, middle background-color: rosybrown # 4.2 Indicar el título y la nota de cada película en su año correspondiente. --- ## 4.2 Indicar el título y la nota de cada película. ```r for(year in rownames(tabla.pos)){ n.frec <- tabla.pos[year,3] if(n.frec > 0){ y.pos <- seq(tabla.pos[year,1], tabla.pos[year,2], length.out = n.frec+2)[2:(n.frec+1)] points(rep(1.15, n.frec), y.pos, pch = "-") * text(x = 1.3, y = y.pos, adj = 0, cex = 0.6, * labels = paste0(imdb.ordporfecha$Pelicula[imdb.ordporfecha$Fecha == year], * " [Nota = ", imdb.ordporfecha$Nota[imdb.ordporfecha$Fecha == year], "]")) }} ``` <img src="Slides_files/figure-html/unnamed-chunk-86-1.png" style="display: block; margin: auto;" /> --- class: center, middle background-color: rosybrown # 4.3 Colorear los nombres de las películas según su rango de puntuación. --- ## 4.3 Colorear los nombres de las películas según su rango de puntuación. ```r for(year in rownames(tabla.pos)){ n.frec <- tabla.pos[year,3] if(n.frec > 0){ y.pos <- seq(tabla.pos[year,1], tabla.pos[year,2], length.out = n.frec+2)[2:(n.frec+1)] points(rep(1.15, n.frec), y.pos, pch = "-") text(x = 1.3, y = y.pos, adj = 0, cex = 0.6, labels = paste0(imdb.ordporfecha$Pelicula[imdb.ordporfecha$Fecha == year], " [Nota = ", imdb.ordporfecha$Nota[imdb.ordporfecha$Fecha == year], "]"), * col = imdb.ordporfecha$ColorNota[imdb.ordporfecha$Fecha == year]) }} ``` --- ## 4.3 Colorear los nombres de las películas según su rango de puntuación. <img src="Slides_files/figure-html/unnamed-chunk-88-1.png" style="display: block; margin: auto;" /> --- ## Añadir la leyenda. ```r legend(x = 6, y = max(opt.barplot), title = "Nota", title.adj = 0, levels(imdb.ordporfecha$NotaGrupo), col = brewer.pal(9, "YlOrRd")[5:9], lwd = 5, cex = 0.8, bty = "n") ``` --- ## Añadir la leyenda. <img src="Slides_files/figure-html/unnamed-chunk-90-1.png" style="display: block; margin: auto;" /> --- # 5. Guardarlo en un PDF con anchura 7 inches (p. defecto) y altura 45 inches. .scrollable[ ```r imdb.ordporfecha <- imdb[order(imdb$Fecha, decreasing = TRUE),] imdb.ordporfecha$NotaGrupo <- cut(imdb.ordporfecha$Nota, breaks = c(8,8.25,8.5,8.75,9,9.25), include.lowest = TRUE) library(RColorBrewer) imdb.ordporfecha$ColorNota <- imdb.ordporfecha$NotaGrupo levels(imdb.ordporfecha$ColorNota) <- brewer.pal(9, "YlOrRd")[5:9] imdb.ordporfecha$ColorNota <- as.character(imdb.ordporfecha$ColorNota) frec.fechas <- table(imdb.ordporfecha$Fecha) frec.every.year <- table(factor(imdb.ordporfecha$Fecha, levels = max(imdb.ordporfecha$Fecha):min(imdb.ordporfecha$Fecha))) ptos.finales <- cumsum(frec.every.year + 1) + espacio*(1:length(frec.every.year)) ptos.iniciales <- c(espacio, ptos.finales[-length(ptos.finales)] + espacio) tabla.pos <- cbind(ptos.iniciales, ptos.finales, frec.every.year) rownames(tabla.pos) <- names(frec.every.year) *pdf("Peliculas_top250_cronologico.pdf", height = 45) espacio <- 0.5 opt.barplot <- barplot(height = ifelse(frec.every.year == 0, 0, 1), width = frec.every.year + 1, horiz = TRUE, xlim = c(0,10), cex.names = 0.7, las = 2, axes = FALSE, space = espacio/mean(frec.every.year + 1)) for(year in rownames(tabla.pos)){ n.frec <- tabla.pos[year,3] if(n.frec > 0){ y.pos <- seq(tabla.pos[year,1], tabla.pos[year,2], length.out = n.frec+2)[2:(n.frec+1)] points(rep(1.15, n.frec), y.pos, pch = "-") text(x = 1.3, y = y.pos, adj = 0, cex = 0.6, labels = paste0(imdb.ordporfecha$Pelicula[imdb.ordporfecha$Fecha == year], " [Nota = ", imdb.ordporfecha$Nota[imdb.ordporfecha$Fecha == year], "]"), col = imdb.ordporfecha$ColorNota[imdb.ordporfecha$Fecha == year]) } } legend(x = 6, y = max(opt.barplot), title = "Nota", title.adj = 0, levels(imdb.ordporfecha$NotaGrupo), col = brewer.pal(9, "YlOrRd")[5:9], lwd = 5, cex = 0.8, bty = "n") *dev.off() ``` ] --- class: center, middle background-color: rosybrown # The End --- background-color: rosybrown # Recomendaciones: * [.black[¿Cómo buscar el gráfico más adecuado para tus datos? from Data to Viz]](https://www.data-to-viz.com/) * [.black[Curso de visualización con `ggplot2`]](https://datavizs21.classes.andrewheiss.com/lesson/) * [.black[Statistical Inference via Data Science: A ModernDive into R and the Tidyverse]](https://moderndive.com/index.html) * [.black[Resumen de expresiones regulares en R]](https://rstudio-pubs-static.s3.amazonaws.com/74603_76cd14d5983f47408fdf0b323550b846.html)