## Your code
i <- 1:1000
result_A1 <- sum(1/i^2)
result$A1 <- result_A1 ## replace NULL with your answer (by replacing NULL with the variable containing your answer)
\(F_n = F_{n-1} + F_{n-2}\). Given the seed value \(F_1 = 1\) and \(F_2 = 1\), what is \(F_{100}\)? (5 pts)
## Your code
N <- 100
F <- rep(NA, N)
F[1] <- 1
F[2] <- 1
for(n in 3:N){
F[n] <- F[n-1] + F[n-2]
}
result$A2 <- F[N] ## replace NULL with your answer (by replacing NULL with the variable containing your answer)
## Your code
plot(x=cars$speed, y = cars$dist, xlab="speed", ylab="dist", main="dist vs speed")
In R base package, there is mtcars’ data. data(mtcars)
## Your code
lmfit <- lm(mpg ~ cyl + disp + hp + drat, data=mtcars)
## Your code
pvalue <- summary(lmfit)$coefficients["cyl", "Pr(>|t|)"]
result$C2 <- pvalue ## replace NULL with your answer (by replacing NULL with the variable containing your answer)
The chunk of code will verify that the Rdata contains your name, GatorLinkID, answers to all questions
verify <- function(result){
## first verify your basic information, if not, error will come up.
if(is.null(result$firstName)){
stop("firstName is missing")
} else {
cat("Name:", result$firstName, " ")
}
if(is.null(result$lastName)){
stop("lastName is missing")
} else {
cat(result$lastName, "\n")
}
if(is.null(result$GatorLinkID)){
stop("GatorLinkID is missing")
} else {
cat("GatorLinkID:", result$GatorLinkID, "\n")
}
if(is.null(result$teammate)){
cat("You have no teammate\n")
} else {
cat("Your teammate is", result$teammate, "\n")
}
## second verify if you have provide an answer, if not, warning will come up.
completeAnswer <- TRUE
if(is.null(result$A1)) {
warning("Question A1 is answered")
completeAnswer <- FALSE
}
if(is.null(result$A2)) {
warning("Question A2 is answered")
completeAnswer <- FALSE
}
if(is.null(result$C2)) {
warning("Question C2 is answered")
completeAnswer <- FALSE
}
if(completeAnswer) cat("Congratulations! All questions are answered!\n")
}
verify(result) ## verify your result
## Name: your first name your last name
## GatorLinkID: zhuo
## You have no teammate
## Congratulations! All questions are answered!
save(result, file="hw0_Lastname_Firstname.Rdata") ## save your result