Edit the code chunks below and knit the document.

Type commands into the console

In the console, type the following:

1 + 2
a <- 1
b <- 2
a + b

Look at the Environment tab in the upper right pane. Set the variable how_many_objects below to the number of objects listed in the environment.

how_many_objects <- NULL

Understand function syntax

Use the rnorm() function to generate 10 random values from a normal distribution with a mean of 800 and a standard deviation of 20, and store the resulting vector in the object random_vals.

random_vals <- NULL

Use the help function to figure out what argument you need to set to ignore NA values when calculating the mean of the_values. Change the function below to store the mean of the_values in the variable the_mean.

the_values <- c(1,1,1,2,3,4,6,8,9,9, NA) # do not alter this line
the_mean   <- NULL

Figure out what the function seq() does. Use the function to set tens to the vector c(0, 10, 20, 30, 40, 50 ,60, 70 ,80 ,90, 100). Set bins6 to the cutoffs if you wanted to divide the numbers 0 to 100 into 6 bins. For example, dividing 0 to 100 into 4 bins results in the cutoffs c(0, 25, 50, 75, 100),

tens  <- NULL
bins6 <- NULL

Figure out how to use the paste() function to paste together strings with forward slashes (“/”) instead of spaces. Use paste() to set my_dir to “my/project/directory”.

my_dir <- NULL

Install a package

Install the CRAN package called “cowsay”. Run the code to do this and include it in the code chunk below, but comment it out. It is bad practice to write a script that installs a package without the user having the option to cancel. Also, some packages take a long time to load, so you won’t want to install them every time you run a script.

# comment out the installation code

The code below has errors. Fix the code.

cowsay::say)
## Error: <text>:1:12: unexpected ')'
## 1: cowsay::say)
##                ^
cowsay::say(by = pumpkin)
## Error in match.arg(by, c(choices = names(animals), "rms", "random")): object 'pumpkin' not found
cowsay::say(by_colour = "blue")