4 + 6 - (24/6)
(6 - 4) * 3
5 ^ 2

# Example of a comment. This line does NOT get run by the program. 

exp(2) # This is the number e raised to the power within the parentheses
sqrt(4) # Square root
abs(-5) # Absolute value

1:5 # Creates a sequence from 1 to 5
seq(from=1,to=5,by=1) # Constructs the same sequence as above
1:5 + 5 # adds 5 to each element of the sequence

x <- 5 # This assigns the value 5 to the variable x.
# Now we can reference x, and R substitutes in 5.
x
# This is useful for things like 
y <- log(5) + 3/2 # "log" in R is natural log (ln)
y

x <- 2 + 5
x
x <- x + 5
x
x <- y + 5
x

w <- c(2,3,5) # This is an example of storing a vector. 
w

x <- 5 + w
x

X <- c(1, 2, 3)
x <- c(4, 5, 6)
X
x

b <- x[2]
b

lab1 <- read.delim('https://raw.githubusercontent.com/IowaBiostat/data-sets/main/tips/tips.txt')

head(lab1) # Outputs only the first few lines of a dataset
summary(lab1) # Gives summary statistics for the dataset

tips <- lab1$Tip
head(tips)

max(tips) # Largest Tip

# 1a:   
partA <- seq(25, 300, by = 25)
partA

# 1b:
sqrt(partA)

grades <- c(78.3, 90.1, 99.3, 82.1, 68.0) 
grades # print out grades vector

grades_sorted <- sort(grades, decreasing = TRUE)
grades_sorted # print out grades_sorted

grades_sorted[3]

max(grades)

log_bill <- log(lab1$TotBill)
mean(log_bill)
sd(log_bill)
