Q1. Assigning values

height <- 175
height
## [1] 175

Q2. Simple math

25 * 4 - 10
## [1] 90

Q3. Using functions

sqrt(81)
## [1] 9

Q4. Character objects

message <- "R is fun!"
message
## [1] "R is fun!"

Q5. Object manipulation

a <- 10
b <- 5
c <- a + b
c
## [1] 15

Q6. Logical comparison

15 > 20
## [1] FALSE

Q7. Checking classes

class("Hello World")
## [1] "character"

Q8. Code chunk options

No warning argument

log(-1)
## Warning in log(-1): NaNs produced
## [1] NaN

warning=FALSE

log(-1)
## [1] NaN

The warning appeared before adding warning=FALSE. After adding the option, the warning was hidden, but the result was still NaN.

Q9. Code chunk options

No message argument

# Load a package (may produce messages)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

message=FALSE

# Load a package (may produce messages)
library(dplyr)

The package messages appeared before adding message=FALSE. After adding the option, the messages were hidden.

Q10. Creating and analyzing a vector

grades <- c(80, 90, 75, 95, 85)
average <- mean(grades)
average
## [1] 85