Formatting + Summary Statistics

Author

Suggested Answers

Top of the document = YAML (yet another markup language)

Below, we want to accomplish the following:

Packages

Solution: Code chunk arguments are specified at the top of the code chunk using #|. We will mainly use the following below.

message - controls messages in rendered output

warning - controls warnings in rendered output

echo - controls if code is shown or not

eval - controls if code is evaluated or not

Note:

These activities are for YOU to build up your resources to reference LATER.

Solution: We did this by putting double * around YOU and single * around LATER. You can also do this the “word way” by going to the visual tab and clicking the B or I.

Data

For this activity, we are going to use a data set in R called mtcars. Run the glimpse() function on the mtcars data set. What information does this function give us?

glimpse(mtcars)
Rows: 32
Columns: 11
$ mpg  <dbl> 21.0, 21.0, 22.8, 21.4, 18.7, 18.1, 14.3, 24.4, 22.8, 19.2, 17.8,…
$ cyl  <dbl> 6, 6, 4, 6, 8, 6, 8, 4, 4, 6, 6, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 8,…
$ disp <dbl> 160.0, 160.0, 108.0, 258.0, 360.0, 225.0, 360.0, 146.7, 140.8, 16…
$ hp   <dbl> 110, 110, 93, 110, 175, 105, 245, 62, 95, 123, 123, 180, 180, 180…
$ drat <dbl> 3.90, 3.90, 3.85, 3.08, 3.15, 2.76, 3.21, 3.69, 3.92, 3.92, 3.92,…
$ wt   <dbl> 2.620, 2.875, 2.320, 3.215, 3.440, 3.460, 3.570, 3.190, 3.150, 3.…
$ qsec <dbl> 16.46, 17.02, 18.61, 19.44, 17.02, 20.22, 15.84, 20.00, 22.90, 18…
$ vs   <dbl> 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,…
$ am   <dbl> 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0,…
$ gear <dbl> 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 4, 4, 4, 3, 3,…
$ carb <dbl> 4, 4, 1, 1, 2, 1, 4, 2, 2, 4, 4, 3, 3, 3, 4, 4, 4, 1, 2, 1, 1, 2,…

Solution We need the number of rows and columns of the data set. We also see variable names, data types, and a glimpse of what the data set looks like.

Now, let’s practice pulling up a help file for the mtcars data set. How do we do this? Should we write this code in a code chunk or the console?

Solution: We pulled up the help file for the data set by typing ?mtcars in the console. It makes more sense to put this code in the console instead of the quarto file because it is “one-off” code that we do not need in our rendered document.