class: center, middle, inverse, title-slide # ¡Mejor ciencia con rOpenSci! ## Maëlle Salmon
ropensci
ropensci
ropensci.org ### 2018/09/05 --- # ¿Qué es rOpenSci? .font150[ * Una comunidad científica y de desarrollo de software R * Apoyo a la ciencia abierta y reproducible * Paquetes R mantenidos por el personal y la comunidad] -- .font150[Muy bien, pero mejor es ilustrarlo con un ejemplo...] .font150[Diapositivas: [tiny.cc/latinr](https://tiny.cc/latinr)] --- # ¿Dónde están? -- ```r library("opencage") lugar <- opencage_forward("Universidad de Palermo Mario Bravo 1050, Buenos Aires", countrycode = "AR", limit = 1)$results class(lugar) ``` ``` ## [1] "tbl_df" "tbl" "data.frame" ``` A ver... `lugar$annotations.flag` es 🇦🇷. --- # Zona de búsqueda ```r bbox <- bbox::lonlat2bbox(lugar$geometry.lng, lugar$geometry.lat, dist = 1, method = "lawn") bbox ``` ``` ## [1] -58.4261 -34.6058 -58.4056 -34.5889 ``` --- # ¡Cafés con internet! .font150[OpenStreetMap al rescate.] -- ```r cafes <- osmdata::opq(bbox = bbox) %>% osmdata::add_osm_feature(key = 'amenity', value = 'cafe') %>% osmdata::add_osm_feature(key = 'internet_access') %>% osmdata::osmdata_sf() cafes$osm_points ``` --- # ¡Cafés con internet! .font150[OpenStreetMap al rescate.] ```r cafes <- osmdata::opq(bbox = bbox) %>% osmdata::add_osm_feature(key = 'amenity', value = 'cafe') %>% osmdata::add_osm_feature(key = 'internet_access') %>% osmdata::osmdata_sf() cafes$osm_points ``` ``` ## Simple feature collection with 10 features and 35 fields ## geometry type: POINT ## dimension: XY ## bbox: xmin: -58.42581 ymin: -34.60393 xmax: -58.41013 ymax: -34.58968 ## epsg (SRID): 4326 ## proj4string: +proj=longlat +datum=WGS84 +no_defs ## osm_id name addr.city ## 1719003358 1719003358 Starbucks Ciudad Autónoma de Buenos Aires ## 3061558889 3061558889 593 coffee <NA> ## 3416791033 3416791033 Starbucks <NA> ## 3763398421 3763398421 McDonald's Cafe Ciudad Autónoma de Buenos Aires ## 4673693845 4673693845 Café MartÃnez Ciudad Autónoma de Buenos Aires ## 5269980463 5269980463 Le Blé Ciudad Autónoma de Buenos Aires ## 5269980474 5269980474 Le Blé Ciudad Autónoma de Buenos Aires ## 5664810922 5664810922 Café MartÃnez Ciudad Autónoma de Buenos Aires ## 5685393114 5685393114 Café MartÃnez Ciudad Autónoma de Buenos Aires ## 5777057654 5777057654 Cremolatti <NA> ## addr.country addr.housename addr.housenumber addr.postcode ## 1719003358 <NA> Abasto <NA> <NA> ## 3061558889 <NA> <NA> 1195 <NA> ## 3416791033 <NA> Fuentes de Malabia 1720 C1414DMJ ## 3763398421 <NA> <NA> <NA> <NA> ## 4673693845 AR <NA> 3301 1193 ## 5269980463 AR <NA> 4109 1425 ## 5269980474 AR <NA> 908 1175 ## 5664810922 AR <NA> 3799 1194 ## 5685393114 AR <NA> 1790 1425 ## 5777057654 <NA> <NA> 1499 <NA> ## addr.street amenity cuisine delivery drive_through ## 1719003358 <NA> cafe coffee_shop <NA> <NA> ## 3061558889 Mario Bravo cafe <NA> <NA> <NA> ## 3416791033 Malabia cafe <NA> <NA> <NA> ## 3763398421 <NA> cafe coffee_shop <NA> <NA> ## 4673693845 Avenida Corrientes cafe <NA> no no ## 5269980463 Avenida Honduras cafe <NA> <NA> <NA> ## 5269980474 Mario Bravo cafe <NA> <NA> <NA> ## 5664810922 Avenida Corrientes cafe <NA> no no ## 5685393114 Bulnes cafe <NA> no no ## 5777057654 Jerónimo Salguero cafe <NA> <NA> <NA> ## email ## 1719003358 <NA> ## 3061558889 <NA> ## 3416791033 <NA> ## 3763398421 <NA> ## 4673693845 abasto@cafemartinez.com.ar ## 5269980463 honduras@leble.com.ar ## 5269980474 almagro@leble.com.ar ## 5664810922 corrientesybulnes@cafemartinez.com.ar ## 5685393114 bulnes@cafemartinez.com.ar ## 5777057654 <NA> ## facebook ## 1719003358 <NA> ## 3061558889 <NA> ## 3416791033 <NA> ## 3763398421 <NA> ## 4673693845 https://www.facebook.com/CafeMartinezSitioOficial/ ## 5269980463 https://www.facebook.com/lebleofical/ ## 5269980474 https://www.facebook.com/lebleofical/ ## 5664810922 https://www.facebook.com/CafeMartinezSitioOficial/ ## 5685393114 https://www.facebook.com/CafeMartinezSitioOficial/ ## 5777057654 <NA> ## instagram internet_access ## 1719003358 <NA> wlan ## 3061558889 <NA> wlan ## 3416791033 <NA> wlan ## 3763398421 <NA> wlan ## 4673693845 https://www.instagram.com/cafemartinezoficial/ wlan ## 5269980463 https://www.instagram.com/lebleoficial/ wlan ## 5269980474 https://www.instagram.com/lebleoficial/ wlan ## 5664810922 https://www.instagram.com/cafemartinezoficial/ wlan ## 5685393114 https://www.instagram.com/cafemartinezoficial/ wlan ## 5777057654 <NA> wlan ## internet_access.fee ## 1719003358 <NA> ## 3061558889 <NA> ## 3416791033 no ## 3763398421 <NA> ## 4673693845 <NA> ## 5269980463 no ## 5269980474 no ## 5664810922 <NA> ## 5685393114 <NA> ## 5777057654 <NA> ## opening_hours ## 1719003358 <NA> ## 3061558889 <NA> ## 3416791033 Mo-Th 07:30-23:00; Fr 07:30-24:00; Sa 00:00-02:30,09:00-24:00; Su 00:00-04:00,09:15-23:00 ## 3763398421 <NA> ## 4673693845 Mo-Su 08:00-21:30 ## 5269980463 Mo-Su 08:00-20:00 ## 5269980474 Su-Th 08:00-20:00; Fr,Sa 08:00-21:00 ## 5664810922 Mo-Su 08:00-21:00 ## 5685393114 Mo-Su 08:00-22:00 ## 5777057654 <NA> ## outdoor_seating payment.american_express payment.cash ## 1719003358 <NA> <NA> <NA> ## 3061558889 <NA> <NA> <NA> ## 3416791033 <NA> yes yes ## 3763398421 <NA> <NA> <NA> ## 4673693845 no <NA> <NA> ## 5269980463 yes <NA> <NA> ## 5269980474 yes <NA> <NA> ## 5664810922 yes <NA> <NA> ## 5685393114 yes <NA> <NA> ## 5777057654 <NA> <NA> <NA> ## payment.cryptocurrencies payment.maestro payment.mastercard ## 1719003358 <NA> <NA> <NA> ## 3061558889 <NA> <NA> <NA> ## 3416791033 no yes yes ## 3763398421 <NA> <NA> <NA> ## 4673693845 <NA> <NA> <NA> ## 5269980463 <NA> <NA> <NA> ## 5269980474 <NA> <NA> <NA> ## 5664810922 <NA> <NA> <NA> ## 5685393114 <NA> <NA> <NA> ## 5777057654 <NA> <NA> <NA> ## payment.visa payment.visa_debit phone smoking ## 1719003358 <NA> <NA> <NA> outside ## 3061558889 <NA> <NA> <NA> <NA> ## 3416791033 yes yes +54 11 5530-7000 no ## 3763398421 <NA> <NA> <NA> no ## 4673693845 <NA> <NA> +54 11 4862-1501 <NA> ## 5269980463 <NA> <NA> +54 11 4864-2814 <NA> ## 5269980474 <NA> <NA> +54 11 4862-5673 <NA> ## 5664810922 <NA> <NA> +54 11 4862-2395 <NA> ## 5685393114 <NA> <NA> +54 11 4827-2755 <NA> ## 5777057654 <NA> <NA> <NA> <NA> ## takeaway twitter ## 1719003358 <NA> <NA> ## 3061558889 <NA> <NA> ## 3416791033 <NA> <NA> ## 3763398421 <NA> <NA> ## 4673693845 yes https://www.twitter.com/cafemartinez/ ## 5269980463 yes https://twitter.com/lebleoficial/ ## 5269980474 yes https://twitter.com/lebleoficial/ ## 5664810922 yes https://www.twitter.com/cafemartinez/ ## 5685393114 yes https://www.twitter.com/cafemartinez/ ## 5777057654 <NA> <NA> ## website wheelchair wifi wikidata ## 1719003358 http://www.starbucks.com.ar yes free <NA> ## 3061558889 <NA> <NA> <NA> <NA> ## 3416791033 http://www.starbucks.com.ar/ yes <NA> <NA> ## 3763398421 <NA> yes <NA> <NA> ## 4673693845 http://www.cafemartinez.com/ <NA> <NA> Q16540032 ## 5269980463 http://www.leble.com.ar/ <NA> <NA> <NA> ## 5269980474 http://www.leble.com.ar/ <NA> <NA> <NA> ## 5664810922 http://www.cafemartinez.com/ <NA> <NA> Q16540032 ## 5685393114 http://www.cafemartinez.com/ <NA> <NA> Q16540032 ## 5777057654 <NA> <NA> <NA> <NA> ## wikipedia geometry ## 1719003358 <NA> POINT (-58.41013 -34.60294) ## 3061558889 <NA> POINT (-58.41498 -34.59567) ## 3416791033 <NA> POINT (-58.42581 -34.58968) ## 3763398421 <NA> POINT (-58.41045 -34.6036) ## 4673693845 es:Café MartÃnez POINT (-58.4118 -34.60393) ## 5269980463 <NA> POINT (-58.42122 -34.59392) ## 5269980474 <NA> POINT (-58.4162 -34.59911) ## 5664810922 es:Café MartÃnez POINT (-58.41788 -34.60334) ## 5685393114 es:Café MartÃnez POINT (-58.41421 -34.59064) ## 5777057654 <NA> POINT (-58.41794 -34.59289) ``` --- # ¡Calles! ```r calles <- osmdata::opq(bbox = bbox) %>% osmdata::add_osm_feature(key = 'highway') %>% osmdata::osmdata_sf() calles$osm_lines ``` --- # ¡Calles! ```r calles <- osmdata::opq(bbox = bbox) %>% osmdata::add_osm_feature(key = 'highway') %>% osmdata::osmdata_sf() calles$osm_lines ``` ``` ## Simple feature collection with 402 features and 49 fields ## geometry type: LINESTRING ## dimension: XY ## bbox: xmin: -58.43229 ymin: -34.60863 xmax: -58.39917 ymax: -34.58505 ## epsg (SRID): 4326 ## proj4string: +proj=longlat +datum=WGS84 +no_defs ## First 10 features: ## osm_id name access area barrier bicycle ## 9940858 9940858 Viamonte <NA> <NA> <NA> <NA> ## 9940907 9940907 José Antonio Cabrera <NA> <NA> <NA> <NA> ## 9940930 9940930 Gorriti <NA> <NA> <NA> designated ## 10054961 10054961 Laprida <NA> <NA> <NA> <NA> ## 10426272 10426272 Avenida Estado de Israel <NA> <NA> <NA> <NA> ## 10426275 10426275 Rauch <NA> <NA> <NA> <NA> ## 10428208 10428208 Pringles <NA> <NA> <NA> <NA> ## 10596745 10596745 Güemes <NA> <NA> <NA> <NA> ## 10596907 10596907 El Salvador <NA> <NA> <NA> <NA> ## 10806992 10806992 Soler <NA> <NA> <NA> <NA> ## crossing cycleway cycleway.both cycleway.left ## 9940858 <NA> <NA> <NA> <NA> ## 9940907 <NA> <NA> <NA> <NA> ## 9940930 <NA> opposite_track <NA> <NA> ## 10054961 <NA> <NA> <NA> <NA> ## 10426272 <NA> <NA> <NA> <NA> ## 10426275 <NA> <NA> <NA> <NA> ## 10428208 <NA> <NA> <NA> <NA> ## 10596745 <NA> <NA> <NA> <NA> ## 10596907 <NA> <NA> <NA> <NA> ## 10806992 <NA> <NA> <NA> <NA> ## cycleway.right description dog emergency foot footway goods ## 9940858 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## 9940907 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## 9940930 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## 10054961 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## 10426272 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## 10426275 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## 10428208 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## 10596745 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## 10596907 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## 10806992 <NA> <NA> <NA> <NA> <NA> <NA> <NA> ## handrail hazard highway horse incline landcover lanes ## 9940858 <NA> <NA> residential <NA> <NA> <NA> 1 ## 9940907 <NA> school_zone residential <NA> <NA> <NA> 2 ## 9940930 <NA> <NA> residential <NA> <NA> <NA> <NA> ## 10054961 <NA> <NA> residential <NA> <NA> <NA> <NA> ## 10426272 <NA> <NA> secondary <NA> <NA> <NA> 4 ## 10426275 <NA> <NA> residential <NA> <NA> <NA> <NA> ## 10428208 <NA> <NA> residential <NA> <NA> <NA> 2 ## 10596745 <NA> <NA> residential <NA> <NA> <NA> <NA> ## 10596907 <NA> school_zone residential <NA> <NA> <NA> <NA> ## 10806992 <NA> <NA> residential <NA> <NA> <NA> <NA> ## lanes.backward lanes.forward layer leisure lit maxspeed ## 9940858 <NA> <NA> <NA> <NA> <NA> 40 ## 9940907 <NA> <NA> <NA> <NA> <NA> 20 ## 9940930 <NA> <NA> <NA> <NA> <NA> 30 ## 10054961 <NA> <NA> <NA> <NA> <NA> 40 ## 10426272 <NA> <NA> <NA> <NA> <NA> 60 ## 10426275 <NA> <NA> <NA> <NA> <NA> 40 ## 10428208 <NA> <NA> <NA> <NA> <NA> 40 ## 10596745 <NA> <NA> <NA> <NA> <NA> 40 ## 10596907 <NA> <NA> <NA> <NA> <NA> 40 ## 10806992 <NA> <NA> <NA> <NA> <NA> 40 ## maxspeed.conditional ## 9940858 <NA> ## 9940907 40 @ (Mo-Fr 00:00-07:00,18:00-24:00;Sa-Su 00:00-24:00) ## 9940930 <NA> ## 10054961 <NA> ## 10426272 <NA> ## 10426275 <NA> ## 10428208 <NA> ## 10596745 <NA> ## 10596907 <NA> ## 10806992 <NA> ## motor_vehicle motor_vehicle.backward.conditional motorcar note ## 9940858 <NA> <NA> <NA> <NA> ## 9940907 <NA> <NA> <NA> <NA> ## 9940930 <NA> <NA> <NA> <NA> ## 10054961 <NA> <NA> <NA> <NA> ## 10426272 <NA> <NA> <NA> <NA> ## 10426275 <NA> <NA> <NA> <NA> ## 10428208 <NA> <NA> <NA> <NA> ## 10596745 <NA> <NA> <NA> <NA> ## 10596907 <NA> <NA> <NA> <NA> ## 10806992 <NA> <NA> <NA> <NA> ## oneway oneway.bicycle oneway.psv proposed psv psv.lanes.forward ## 9940858 yes <NA> <NA> <NA> <NA> <NA> ## 9940907 yes <NA> <NA> <NA> <NA> <NA> ## 9940930 yes <NA> <NA> <NA> <NA> <NA> ## 10054961 yes <NA> <NA> <NA> <NA> <NA> ## 10426272 yes <NA> <NA> <NA> <NA> <NA> ## 10426275 yes <NA> <NA> <NA> <NA> <NA> ## 10428208 yes <NA> <NA> <NA> <NA> <NA> ## 10596745 yes <NA> <NA> <NA> <NA> <NA> ## 10596907 yes <NA> <NA> <NA> <NA> <NA> ## 10806992 yes <NA> <NA> <NA> <NA> <NA> ## service sidewalk sloped_curb smoothness surface tunnel ## 9940858 <NA> <NA> <NA> <NA> asphalt <NA> ## 9940907 <NA> <NA> <NA> <NA> asphalt <NA> ## 9940930 <NA> <NA> <NA> <NA> asphalt <NA> ## 10054961 <NA> <NA> <NA> <NA> asphalt <NA> ## 10426272 <NA> <NA> <NA> <NA> asphalt <NA> ## 10426275 <NA> <NA> <NA> <NA> <NA> <NA> ## 10428208 <NA> <NA> <NA> <NA> cobblestone <NA> ## 10596745 <NA> <NA> <NA> <NA> <NA> <NA> ## 10596907 <NA> <NA> <NA> <NA> <NA> <NA> ## 10806992 <NA> <NA> <NA> <NA> asphalt <NA> ## wheelchair width geometry ## 9940858 <NA> <NA> LINESTRING (-58.40759 -34.6... ## 9940907 <NA> <NA> LINESTRING (-58.42419 -34.5... ## 9940930 <NA> <NA> LINESTRING (-58.42302 -34.5... ## 10054961 <NA> <NA> LINESTRING (-58.40424 -34.5... ## 10426272 <NA> <NA> LINESTRING (-58.42336 -34.5... ## 10426275 <NA> <NA> LINESTRING (-58.42052 -34.6... ## 10428208 <NA> <NA> LINESTRING (-58.42365 -34.5... ## 10596745 <NA> <NA> LINESTRING (-58.41117 -34.5... ## 10596907 <NA> <NA> LINESTRING (-58.41934 -34.5... ## 10806992 <NA> <NA> LINESTRING (-58.42223 -34.5... ``` --- # Mapa ```r library("ggplot2") ggplot() + geom_sf(data = calles$osm_lines) + geom_sf(data = cafes$osm_points, size = 4) + annotate("point", lugar$geometry.lng, lugar$geometry.lat, col = "blue", size = 4) + theme_void() + coord_sf(datum = NA) ``` --- # Mapa <img src="slides_files/figure-html/mapa-1.png" style="display: block; margin: auto;" /> --- # ¡Compartamos el código! -- ```r gist <- gistr::gist_create(files = "slides.Rmd", description = "Mi codigo abieRto", public = TRUE) gist ``` ``` ## <gist>1d4322c3de8b691d7d527dab9ac248c7 ## URL: https://gist.github.com/1d4322c3de8b691d7d527dab9ac248c7 ## Description: Mi codigo abieRto ## Public: TRUE ## Created/Edited: 2018-08-23T10:11:29Z / 2018-08-23T10:11:29Z ## Files: slides.Rmd ## Truncated?: FALSE ``` --- # ¡Código abieRto! ```r webshot::webshot("https://gist.github.com/maelle/1d4322c3de8b691d7d527dab9ac248c7", cliprect = "viewport") ``` <img src="slides_files/figure-html/webshot-1.png" style="display: block; margin: auto;" /> --- # Paquetes de rOpenSci .font150[`opencage`, `bbox`, `osmdata`, `gistr`.] -- .font150[rOpenSci mantiene paquetes para] -- * .font150[acceso a fuentes de datos de la web] -- * .font150[acceso a fuentes de datos... raras (PDF con `pdftools` y `tabulizer`, texto en imágenes con `tesseract`)] -- * .font150[herramientas de flujo de trabajo (`drake`)] -- * .font150[y mucho más! https://ropensci.org/packages/] --- # Paquetes de rOpenSci <img src="slides_files/figure-html/webshot2-1.png" style="display: block; margin: auto;" /> --- # Paquetes de calidad .font150[ * Paquetes desarrollados por quienes trabajamos en rOpenSci o por la comunidad * ¡Sistema de revisión de paquetes!] -- .font150[rOpenSci onboarding. https://ropensci.github.io/dev_guide/ Guía de buenas prácticas y descripción del sistema ] --- # Otros recursos de rOpenSci -- * .font150[Blog con ejemplos [ropensci.org/blog](https://ropensci.org/blog)] -- * .font150[Community calls con videos [communitycalls.ropensci.org/](https://communitycalls.ropensci.org/)] -- * .font150[2 organizaciones GitHub [github.com/ropensci](https://github.com/ropensci/) y [github.com/ropenscilabs](https://github.com/ropenscilabs/)] --- # Otros recursos de rOpenSci ```r rtweet::tweet_shot("1027284412571045888") %>% magick::image_crop("517x300+0+90") ``` <img src="slides_files/figure-html/tweet-1.png" width="689" style="display: block; margin: auto;" /> --- # ¡Participen! -- * .font150[Twitter y newsletter para las últimas noticias https://twitter.com/rOpenSci] -- * .font150[Forum para preguntar y discutir [discuss.ropensci.org/](https://discuss.ropensci.org/)] -- * .font150[Envíen o revisen paquetes [github.com/ropensci/onboarding](https://github.com/ropensci/onboarding)] -- --- # Compartan sus experiencias .font150[Si utilizan paquetes de rOpenSci, ¡escríbanlo en el forum!! Ejemplo de post en español utilizando `pdftools`:"Scrapeando las Sesiones Parlamentarias de Uruguay" por Daniela Vázquez https://d4tagirl.com/2018/04/scrapeando-las-sesiones-parlamentarias-de-uruguay ] --- # Discusión -- ```r personas <- c("jennybc", "lauracion", "maurolepore") roles <- c("leadership", "community", "community") glue::glue("https://github.com/{personas}.png") %>% magick::image_read() %>% magick::image_resize("200x200") %>% as.list() %>% # mi funcion (magick::image_annotate vectorizada) images_annotate(glue::glue(" rOpenSci {roles} "))%>% magick::image_join() %>% magick::image_append() ``` <div class="figure" style="text-align: center"> <img src="slides_files/figure-html/unnamed-chunk-2-1.png" alt="people leading the discussion" width="800" /> <p class="caption">people leading the discussion</p> </div> --- # ¡Gracias! .font150[rOpenSci, *comunidad* científica y de desarrollo de <i class="fab fa-r-project "></i> para apoyar a la *ciencia abierta y reproducible*] .font150[ <i class="fab fa-twitter "></i> rOpenSci <i class="fab fa-github "></i> ropensci <i class="fa fa-bookmark "></i> ropensci.org <i class="fa fa-rocket "></i> hasta luego!] .font150[Diapositivas: [tiny.cc/latinr](https://tiny.cc/latinr)] ---