class: center, middle, inverse, title-slide # Essentials 08: Common ErroRs --- class: inverse # Common ErroRs & Debugging R Code Different types of *helpful* info is displayed when there are problems with our code: -- .green.bold[Messages] - the good 😇 - Often harmless & can sometimes be ignored (i.e. when loading packages) - Can sometimes hint that something might be wrong or missing -- .orange.bold[Warnings] - the bad 😈 - Function is executed but something unusual is happening - Can highlight potential problems -- .red.bold[Errors] - the ugly 👹😱 - Fatal - stops the execution & evaluation of any code - Must be solved for code to run & document to knit --- class: inverse # Common Causes of ErroRs Keep these in mind when debugging your own code! - Spellig errors, tYpos, incorrect Capitalization & s p a c e s - Missing/too many commas, speech marks, brackets, underscores & back ticks - Packages not installed/loaded & install.packages commands in code chunks - Duplicate code chunk labels - Objects being called on *before* they are created - Missing arguments/inputs of functions - Incorrect order of function arguments --- class: inverse # What To Do? -- .orange[Step 1]: Don't panic - read the error message for clues 🕵 -- .orange[Step 2]: Find where the error is 📍 - Error messages in the console tend to give an approx. location of where the problem lies - Look for red underline & red crosses - Run/knit each chunk in turn from top to bottom - Run each line of code in a chunk/each step of a pipeline %>% -- .orange[Step 3]: Check over code for common mistakes 👀 - Typos, brackets, commas, speech marks, spaces.. -- .orange[Step 4]: Check the output from a function is what you're expecting 🔍 -- .orange[Step 5]: Use the help pane & package documentation to check function arguments & ordering 📂 -- .orange[Step 6]: Search the error message online 💻🕸 --- class: inverse # Common Error Messages #### .orange[Task]: Tell me some possible causes & solutions in the chat! <br> <img src="images/data.png" width="1028" /> --- class: inverse # Common Error Messages #### .orange[Task]: Tell me some possible causes & solutions in the chat! <br> <img src="images/ntfound.png" width="1025" /> --- class: inverse # Common Error Messages #### .orange[Task]: Tell me some possible causes & solutions in the chat! <br> <img src="images/pipe.png" width="1029" /> --- class: inverse # Common Error Messages #### .orange[Task]: Tell me some possible causes & solutions in the chat! <br> <img src="images/dupchunk.png" width="1025" /> --- class: inverse # Common Error Messages #### .orange[Task]: Tell me some possible causes & solutions in the chat! <br> <img src="images/ggpipe.png" width="75%" /> --- class: inverse # Common Error Messages #### .orange[Task]: Tell me some possible causes & solutions in the chat! <br> <img src="images/knitpckg.png" width="1029" /> --- class: inverse # Common Error Messages #### .orange[Task]: Tell me some possible causes & solutions in the chat! <br> <img src="images/mask.png" width="1361" /> --- class: inverse # Common Error Messages #### .orange[Task]: Tell me some possible causes & solutions in the chat! <br> <img src="images/namespc.png" width="1485" /> <br> <br> <br> <br> <br> <br> <br> <br> .b[ Image taken from [Y. Wendy Huynh's R for Graduate Students Book](https://bookdown.org/yih_huynh/Guide-to-R-Book/trouble.html) ] --- class: center, middle <div class="padlet-embed" style="border:1px solid rgba(0,0,0,0.1);border-radius:2px;box-sizing:border-box;overflow:hidden;position:relative;width:100%;background:#F4F4F4"><p style="padding:0;margin:0"><iframe src="https://uofsussex.padlet.org/embed/nrud4gk8x63gbfdc" frameborder="0" allow="camera;microphone;geolocation" style="width:100%;height:608px;display:block;padding:0;margin:0"></iframe></p><div style="padding:8px;text-align:right;margin:0;"><a href="https://padlet.com?ref=embed" style="padding:0;margin:0;border:none;display:block;line-height:1;height:16px" target="_blank"><img src="https://padlet.net/embeds/made_with_padlet.png" width="86" height="16" style="padding:0;margin:0;background:none;border:none;display:inline;box-shadow:none" alt="Made with Padlet"></a></div></div>