+ - 0:00:00
Notes for current slide
Notes for next slide

Troubleshooting & Debugging

Bora Jin

1 / 12

Today's Goal

  • Learn troubleshooting strategies
  • Practice debugging some common errors

"Each time you figure out the solution to your problem, you acquire more and more knowledge about how and why things go wrong, and more confidence about how to tackle the next glitch that comes along." - from today's material

3 / 12

Quiz

Functions take inputs, perform actions, and return outputs.

Q - In an R help page, which sections do we read for information on how to use the function?

4 / 12

Quiz

Functions take inputs, perform actions, and return outputs.

Q - In an R help page, which sections do we read for information on how to use the function?

Usage

4 / 12

Quiz

Functions take inputs, perform actions, and return outputs.

Q - In an R help page, which sections do we read for information on how to use the function?

Usage

  • function's name
  • named arguments in () in the order the function expects the arguments
  • some arguments come with default values
  • but you must specify values for arguments without default values
4 / 12

Quiz

Q - In an R help page, which sections do we read for information on inputs?

5 / 12

Quiz

Q - In an R help page, which sections do we read for information on inputs?

Arguments

5 / 12

Quiz

Q - In an R help page, which sections do we read for information on inputs?

Arguments

  • detailed information on each argument
  • it tells you the class of inputs that the function expects
5 / 12

Quiz

Q - In an R help page, which sections do we read for information on inputs?

Arguments

  • detailed information on each argument
  • it tells you the class of inputs that the function expects

Q - In an R help page, which sections do we read for information on actions?

5 / 12

Quiz

Q - In an R help page, which sections do we read for information on inputs?

Arguments

  • detailed information on each argument
  • it tells you the class of inputs that the function expects

Q - In an R help page, which sections do we read for information on actions?

Description or title

5 / 12

Quiz

Q - In an R help page, which sections do we read for information on inputs?

Arguments

  • detailed information on each argument
  • it tells you the class of inputs that the function expects

Q - In an R help page, which sections do we read for information on actions?

Description or title

  • describes what the function does
5 / 12

Quiz

Q - In an R help page, which sections do we read for information on outputs?

6 / 12

Quiz

Q - In an R help page, which sections do we read for information on outputs?

Value

6 / 12

Quiz

Q - In an R help page, which sections do we read for information on outputs?

Value

  • function's output in the order the function returns values
  • can be a single number, a list with multiple objects, a data frame, a plot, or a model
6 / 12

Quiz

Q - In an R help page, which sections do we read for information on examples?

7 / 12

Quiz

Q - In an R help page, which sections do we read for information on examples?

Examples

7 / 12

Quiz

Q - In an R help page, which sections do we read for information on examples?

Examples

  • simple and quick-to-run examples to help you understand how to use the function and what to use it on
7 / 12

Quiz

Q - In an R help page, which sections do we read for information on examples?

Examples

  • simple and quick-to-run examples to help you understand how to use the function and what to use it on

Q - What if we want to learn more about the package as a whole, rather than a few specific functions?

7 / 12

Quiz

Q - In an R help page, which sections do we read for information on examples?

Examples

  • simple and quick-to-run examples to help you understand how to use the function and what to use it on

Q - What if we want to learn more about the package as a whole, rather than a few specific functions?

Demos and Vignettes

7 / 12

Quiz

Q - In an R help page, which sections do we read for information on examples?

Examples

  • simple and quick-to-run examples to help you understand how to use the function and what to use it on

Q - What if we want to learn more about the package as a whole, rather than a few specific functions?

Demos and Vignettes

  • you may google directly the package name
  • or click the link at the end of the help page to visit the package's index page
7 / 12

Example

?qnorm
8 / 12

Example

?qnorm
?lm
8 / 12

Example

qnorm(0.5) # default values
## [1] 0
9 / 12

Example

qnorm(0.5) # default values
## [1] 0
qnorm(0.5, 2, 1) # in default order
## [1] 2
9 / 12

Example

qnorm(0.5) # default values
## [1] 0
qnorm(0.5, 2, 1) # in default order
## [1] 2
qnorm(0.5, 1, 2) # mean and sd values swapped
## [1] 1
9 / 12

Example

qnorm(0.5) # default values
## [1] 0
qnorm(0.5, 2, 1) # in default order
## [1] 2
qnorm(0.5, 1, 2) # mean and sd values swapped
## [1] 1
qnorm(0.5, sd = 1, mean = 2) # mean and sd order swapped but same as qnorm(0.5, 2, 1)
## [1] 2
9 / 12

Questions?

10 / 12

Bulletin

  • Watch videos for Prepare: May 25

  • HW 01 due tonight at 11:59pm

  • Submit your ae08 and ae09

12 / 12
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow