class: center, middle, inverse, title-slide # Fun with R! ## sambaR ### Andrea Sánchez-Tapia
¡liibre! ### R-Ladies+ East Lansing & R-Ladies+ Chicago
April 2021 --- class: inverse, middle, center background-image: url("figs/chevron.png") background-position: 98% 2% background-size: 150px # Fun with R! ## sambaR ### Andrea Sánchez-Tapia <br> ¡liibre! ### R-Ladies+ East Lansing & R-Ladies+ Chicago<br><br> April 2021 --- background-image: url("figs/liibre.png") background-position: 98% 2% background-size: 150px ### .red[About me] + __BSc. Biology__ - Universidad Nacional de Colombia <br> __MSc. in Ecology__ - Rio de Janeiro Federal University <br> __PhD. in Botany__ - Rio de Janeiro Botanical Garden -- + Biodiversity informatics, ecological niche modeling, restoration ecology, quantitative ecology -- + I use R since 2009 and belong to __.purple[R-Ladies+ Rio de Janeiro]__ since 2017 -- + __Open, responsible and reproducible science__, [data feminism](http://datafeminism.io/) -- + __.red[¡liibre!]__ .red[Independent Lab of Biodiversity Informatics and Reproducibility in Ecology"], co-founded with __Dr. Sara Mortara__ --- background-image: url("figs/chevron.png") background-position: 98% 2% background-size: 150px ### Grad course _Data analysis projects using R_ .pull-left[ <img src="./figs/turma.JPG" width="300" /> __Good practices__ in data analysis ] .pull-right[ <img src="./figs/rstudio.jpg" width="250" /> <img src="./figs/logo_git.png" width="100" /><img src="./figs/logo_github.png" width="100" /><img src="./figs/logo_gitlab.png" width="100" /> <img src="./figs/latex.jpeg" width="120" /><img src="./figs/bibtex.jpeg" width="120" /><img src="./figs/zotero.svg" width="120" /> <img src="./figs/rmarkdown.png" width="100" /><img src="./figs/xaringan.png" width="100" /> ] --- background-image: url("figs/chevron.png") background-position: 98% 2% background-size: 150px ### A brief history of sambaR + My native language is Spanish, that means I grew up <br> trying to understand foreign lyrics on the radio -- + Living in Brazil == _so much new music_ ❤️. Trying to explain your music in Spanish to your new friends and vice-versa -- + I came to the US were I have to explain music from __both countries__ to my newest friends T___T --- background-image: url("figs/chevron.png") background-position: 98% 2% background-size: 150px ### Getting the lyrics: `{genius}` package + Genius database: [https://genius.com/](https://genius.com/) -- + `{Genius}` package: https://josiahparry.com/post/2019-05-08-genius-learnr-tutorial/ -- + `genius::genius_lyrics(artist, song, info = "all")` -- + Create a destination folder for the lyrics to avoid repeating calls to the genius API -- + Save a `.csv` file in a convenient location on disk <large><center> 🎉 --- background-image: url("figs/chevron.png") background-position: 98% 2% background-size: 150px ### Translating the lyrics: `{googleLanguageR}` + Calls the 'Cloud Translation' API for detection and <br> translation of text <https://cloud.google.com/translate/> -- + IRL I am ___very___ afraid of APIs -- + You are charged* by character! 1. Don't make repeated calls -> save! 2. Don't make same language translations -> detect language first! `{cld2}` -- + Locally: configure the API by going to your [cloud.google.com](cloud.google.com) account -> create a __json__ jey, configure your `.Renviron` with that key... --- background-image: url("figs/chevron.png") background-position: 98% 2% background-size: 150px ### Practice other tools + Package building with `{usethis}` + Practice "shiny skills" . 🙄 + Write a small __shiny__ app and learn how it should be included in a package `runExample()` --- ```r # install.packages("remotes") #remotes::install_github("liibre/sambaR") library(sambaR) library(googleLanguageR) song <- translate_lyrics("chico buarque", "apesar de voce") song ``` ``` ## # A tibble: 62 x 1 ## lyric ## <chr> ## 1 Amanhã vai ser outro dia ## 2 Amanhã vai ser outro dia ## 3 Amanhã vai ser outro dia ## 4 Hoje você é quem manda ## 5 Falou, tá falado ## 6 Não tem discussão, não ## 7 A minha gente hoje anda ## 8 Falando de lado e olhando pro chão ## 9 Viu? ## 10 Você que inventou esse Estado ## # … with 52 more rows ``` --- ```r # install.packages("remotes") #remotes::install_github("liibre/sambaR") library(sambaR) library(googleLanguageR) song <- translate_lyrics("chico buarque", "apesar de voce", "en") song ``` ``` ## # A tibble: 62 x 2 ## lyric translation ## <chr> <chr> ## 1 Amanhã vai ser outro dia Tomorrow will be another day ## 2 Amanhã vai ser outro dia Tomorrow will be another day ## 3 Amanhã vai ser outro dia Tomorrow will be another day ## 4 Hoje você é quem manda Today you are the boss ## 5 Falou, tá falado Say, say ## 6 Não tem discussão, não There's no discussion, no ## 7 A minha gente hoje anda My people today walk ## 8 Falando de lado e olhando pro chão Talking sideways and looking at the floor ## 9 Viu? It saw? ## 10 Você que inventou esse Estado You who invented this state ## # … with 52 more rows ``` --- background-image: url("figs/chevron.png") background-position: 98% 2% background-size: 150px ### Fun with R! + Fun is in the eyes of the beholder -- + Curiosity-driven projects help learning things a lot without the pressure for success -- + Don't let anyone tell you that you _need_ to do these kind of things to be better or improve __keep it fun__ --- background-image: url("figs/liibre.png") background-position: 98% 2% background-size: 150px class: center ## Thank you! <svg viewBox="0 0 512 512" style="height:1em;position:relative;display:inline-block;top:.1em;fill:#A70000;" xmlns="http://www.w3.org/2000/svg"> <path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"></path></svg> [@SanchezTapiaA](https://twitter.com/SanchezTapiaA) Registration for __useR! 2021__ is open! <img src="figs/user_logo_COLOR.png" width="350" /><img src="figs/Marmot_mascota_color_TRANS.png" width="350" />