Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R and rstudio basic #15

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1bc8755
Move file from master to individual branch
stephan-koenig May 30, 2020
3100f3b
Fix text formatting and add donwload link for data
stephan-koenig Sep 25, 2020
09c6fca
Apply suggestions from TA code review
stephan-koenig Oct 6, 2020
5d9bcbb
Apply suggestions from code review
cathy-y Oct 17, 2020
a6ab1b7
Apply suggestions from code review
cathy-y Oct 17, 2020
53f8905
Fixed markups for code chunks
cathy-y Oct 23, 2020
4d92829
Restructured order of sections, moved learning objectives to the begi…
cathy-y Oct 24, 2020
d5f518b
Update r_and_rstudio_basic.html
cathy-y Oct 31, 2020
4f3e598
Rewrote questions (and uploaded images to go with them)
cathy-y Oct 31, 2020
2187691
Question revisions
cathy-y Oct 31, 2020
7267170
Removed the working with data section
cathy-y Oct 31, 2020
9c8116b
Changed capitalization
cathy-y Nov 7, 2020
1d952f5
Added section on data types, amended questions
cathy-y Nov 7, 2020
88bf430
Update inst/tutorials/r_and_rstudio_basic/r_and_rstudio_basic.Rmd
cathy-y Nov 9, 2020
9c93172
Added section on vectors and data frames, covered logical operators i…
cathy-y Nov 15, 2020
64ffef4
Started the troubleshooting section
cathy-y Dec 1, 2020
5a98376
Completed getting help section
cathy-y Dec 1, 2020
493826e
Edited the troubleshooting section
cathy-y Dec 6, 2020
ee6ba8e
Added internal links
cathy-y Dec 12, 2020
a9ca887
Updated internal links
cathy-y Dec 12, 2020
11a2ff1
Merge branch 'main' into r-and-rstudio-basic
cathy-y Feb 3, 2021
9e8bd34
Merge branch 'main' into r-and-rstudio-basic
stephan-koenig Feb 3, 2021
b6c988a
Merge branch 'main' into r-and-rstudio-basic
stephan-koenig Mar 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Started the troubleshooting section
  • Loading branch information
cathy-y committed Dec 1, 2020
commit 64ffef4b9f583e8d26926246fa04ad4832f1a9fd
38 changes: 36 additions & 2 deletions inst/tutorials/r_and_rstudio_basic/r_and_rstudio_basic.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ grades <- data.frame(
)
```

```{r df2, exercise=TRUE}
```{r df2, exercise=TRUE, exercise.setup="df"}
grades
```

Expand Down Expand Up @@ -535,7 +535,7 @@ library(tidyverse)

The package `janitor` is used for cleaning up your data. Run the code below to load it:

```{r ade4, exercise=TRUE, error=TRUE}
```{r janitor, exercise=TRUE, error=TRUE}
library(janitor)
```

Expand Down Expand Up @@ -570,3 +570,37 @@ quiz(
)
```

cathy-y marked this conversation as resolved.
Show resolved Hide resolved
## Stuck? A Short Guide to Troubleshooting and Getting Help

If you've been coding for more than an hour, you've definitely had to troubleshoot your code. However, errors can be cryptic, using a new package can be confounding, and, despite your best efforts, you may still end up needing help from someone else. In this section, you'll find a brief, non-exhaustive guide to troubleshooting.

### Tackling Errors

RStudio enables debugging via:

- `traceback()`
- Flagging problematic lines of code

After an error is thrown, RStudio will print the error message in the console and provide you with the option of running the `traceback()` function to identify the source of the error. To give you an idea of what the output looks like, `traceback()` is used as an error handler in the code below, meaning it will automatically run when an error is encountered.

```{r traceback, exercise = TRUE, error = TRUE}
options(error = traceback)

x <- c(1, 2, "three", 4)
y <- c(5, 6, 7, 8)
z <- mean(x)
w <- mean(y)
sum(c(z, w))
```

RStudio also flags problematic lines of code. It's a red dot that appears to the left of your code for lines where something isn't "quite right". Hovering over the red dot provides you with some additional information, but it typically appears when you make a syntax error like forgetting a closing bracket.

You, of course, can also take steps to troubleshoot. Two best practices are:

- Printing out intermediates: If you're running one big function you wrote or stringing together several steps in a row, try running each piece one at a time and printing the output to see where the error is occurring.
- Googling the error: Unless you're doing groundbreaking computer science, someone has encountered your error before. Google the error message verbatim and visit forums like Stack Exchange to get crowdsourced troubleshooting tips.

### Working with New Packages



Loading