class: center, middle, inverse, title-slide # Part 3 ## R Programming ### Jessica Minnier ### 2022-01-18 --- class: center, middle # What do I do with Errors? --- <img src = "image/week3/debugging.jpg" width = 800> --- # Understanding the difference between warnings and errors - A *warning* is an indication that the data or arguments isn't quite what the function expected. - You can usually run the code, but you should be careful about it and verify the output. - An *error* means that the code can't execute at all given what you have given the function. - Errors can be difficult to understand, which is why... --- # Googling is StandaRd pRactice foR eRRors The first thing I do when I encounter an error is to search for the error. I usually start with Google. I don't know everything, and the odds are that I made a mistake in understanding the documentation. There are some resources that I especially check (in order): - google "question + rcran" (i.e "hist rcran" or "make a boxplot ggplot") - google error in quotes (i.e. "Evaluation error: invalid type (closure) for variable '***'") - [RStudio Community (for `tidyverse`)](https://community.rstudio.com/) - [Stack Overflow #r tag](https://stackoverflow.com/questions/tagged/r) - [Biostars (for Bioinformatics)](https://www.biostars.org/) - The package's github page (especially issues) - Advanced search [github](https://github.com/search/advanced?q=language:R) for your function name to see examples or search the error --- # Have someone else look at your code - We all have blind spots - Someone else can more easily find the misplaced `{}`, `()`, or misspellings --- # Usually, the error you're looking for is at the bottom There will usually be a bunch of errors generated, but The one you're interested in is usually the last one. --- # Where do I ask for help? I'm trying to be as helpful as I can, but I can't answer all of your questions. The following communities are extremely helpful to beginners: - [R for Data Science Online Learning Community](https://www.rfordatasci.com/) * Join here: http://r4ds.io/join * Join the slack channel! - [Rstudio community](https://community.rstudio.com/) * to pick on my friend/coworker Emile, [an example](https://community.rstudio.com/t/levels-returns-null-for-a-tibble/110693) - [twitter #rstats](https://twitter.com/search?q=%23rstats&src=typd) --- <img src = "image/week3/here.png" width = 700> --- <img src = "image/week3/dplyr_wrangling.png" width = 700> --- <img src = "image/week3/filter.jpg" width = 800> [`dplyr` cheatsheet](https://rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf) --- <img src = "image/week3/select.jpg" width = 800> [`dplyr` cheatsheet](https://rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf) --- # dplyr cheatsheet Old version: https://rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf New version: https://raw.githubusercontent.com/rstudio/cheatsheets/main/data-transformation.pdf (tidyr has been separated into a separate cheetsheet: https://www.rstudio.com/resources/cheatsheets/)