Appendix A — Answers for Section 3.8

  1. Calculate (89 + 9) / (4*5)^2 and assign the value to the object solution1. Then print solution1.
solution1 <- (89 + 9) / (4 * 5)^2 

[1] 0.245
  1. What is the difference between R and R Studio?

Base R refers to the statistical programming language and application installed on your computer to process the R programming language. RStudio is an Integrated Development Environment (IDE) that integrates with R to provide much more functionality. You can use base R without RStudio, but not the other way around.

  1. How do you add a comment to a Script file?
# Just add a hash/pound sign to the left. 
#### You can add more hashes for aesthetic purposes ####

# Multi-line comments require a hash 
# starting on the left of each line.
  1. What are packages in R, and how do you install them?

R packages are user-written collections of functions, compiled code, and sample data. There are over 9000+ packages in R and counting. We use packages for specific things we want to do that we cannot accomplish with the functions in base R, or to do things easier or more efficiently than base R functions.

Most packages that have been vetted and checked are available on the Comprehensive R Archive Network (CRAN), which is the central R package repository.” “In most cases, installing a package in R is accomplished with the following code install.packages("name of package").

  1. Install and load the package rstudioapi.
  1. How do you modify the appearance of R Studio?

Tools –> Global Options –> Appearance –> Editor Theme.

  1. Assign the value of 365 to an object called year. Then, create another object called months and assign it the value year * 0.032854884083862.
year <- 365
month <- year * 0.032854884083862
  1. Create three variables named Cowboys, Giants, and Commanders and assign them all the value "Inferior Team" using multiple assignment operators.
Cowboys <- Giants <- Commanders <- "Inferior Team"