Week 1

This week is designed to be an introduction week. We will briefly discuss topics related statistics and inference. Then we will look at installing R and RStudio as well as the basics of using R.
Published

August 22, 2022

Learning Outcomes

Monday

  • Define and identify population, sample, parameter, and statistics

  • Define and identify different variable types (quantitative and categorical)

  • Define concept of random samples and sampling methods

Wednesday

  • Installing R, Rstudio, and Quarto

  • Scripts

  • R Packages

  • R Environment

Important Concepts

Monday

Wednesday

Accessing R & RStudio

If you are on a tablet or chromebook, you can access R & RStudio via rstudio.cloud for free. However, they have limited computing resources. Be mindful on your experimentation. You may also be able to use Quarto in Rstudio cloud.

You can install R via their website: https://www.r-project.org/.

You can install RStudio for free from their website: https://www.rstudio.com/products/rstudio/download/

Using R

R can be used as a calculator, below are a few examples:

1+2
[1] 3
3/4
[1] 0.75
9*8
[1] 72
exp(4)
[1] 54.59815

R Functions

R has specialized functions that can compute specific values. R functions requires and inputs, known as arguments, to produce a certain output.

For example, the log() function can be used to compute the natural logarithm of a specified input:

log(34)
[1] 3.526361

If you want to know information about a specific function, you can use the ? operator:

?log

which will open the help tab. Notice there are 2 arguments: x and base. This means that the log() function can be extended to other base. To use common log1, specify the arguments:

log(x=34, base=10)
[1] 1.531479

Notice that I specified the arguments. You can also type this:

log(34, 10)
[1] 1.531479

which produces the same results. This is because R uses positions in the function to determine argument values; therefore, if the positions are correct, you do not need to specify the argument name.

Going back to the first example, log(34), we did not specify the base. This is because functions have default values for arguments. In the help documentation, it tells us what arguments have defaults and not need to be specified.

Resources

Presentations

Monday’s Lecture

Videos

Monday’s Lecture

Wednesday’s Lecture

Footnotes

  1. \(\log_{10}(x)\)↩︎