3 + 5[1] 8
Keep the intro.R script open, but now type directly into the R console below.
3 + 5[1] 8
What happens to the output?
Assign an R object called juice to be equal to 4+4. What is the output when you type juice?
juice <- 4 + 4
# juiceCan you describe what you think x indicates below?
x <- c(1,7,9)
x[2][1] 7
The notation c() in R stands for combine. We used this a lot in R because we are often combining data and comparing it with another dataset.
What do you think the R object fruit is?
apples <- 5
oranges <- 6
fruit <- apples + orangesSymbols in R are used in arguments, logical statements, assignments, and more. We will use many of them, but the common ones
# <- vs. =
a = 3 + 4
a <- 3 + 4# Errors and improper R object naming
# 6389/
# 5-6
# 5.6 <- fruitThere are several ways to view or look at an R object. Can you figure out what they are?
Calculate the volume of a sphere, where the diameter is 20 meters.
Make sure current you keeps track of everything. Future you will Thank past you.
Also use the pound symbol or hashtag mark, “#” to comment out code.
# This code adds the values x and y, creating an R object called 'answer'
answer <- x + y
x <- 5
y <- x^2
## We can set x equal a specific value to define x, y, and answer.