--- title: "Stat 123 Homework 2" author: "Your Name Here" date: "Enter Date" output: word_document --- Using the file given in the instructions, read the daily interest in lds.org for 2014-06-09 through 2014-09-06 into an data.frame. ```{r} data <- read.csv("reportclean.csv") ``` Name the variables in the data.frame "date" and "interest". ```{r} colnames(data)[1] <- "date" colnames(data)[2] <- "interest" ``` Replace the "date" character vector in the data.frame into a vector of Date objects of the same name. ```{r} i_n <- toString(data[1, "date"]) vector1 <- c(as.Date(i_n)) for (row in 2:nrow(data)) { i_n <- toString(data[row, "date"]) vector1 <- c(vector1, as.Date(i_n)) #vector[row] <- as.Date(i_n) } data["date"] <- vector1 ``` Use the "weekdays" function to define a new variable in the data.frame called "weekday" from the "date" variable. ```{r} weekday <- c(weekdays(data[1, "date"])) for (row in 2:nrow(data)) { weekday <- c(weekday,weekdays(data[row, "date"])) } data["weekday"] <- weekday ``` Find the mean of the interest variable across all Mondays. ```{r} weekdays1 <- c('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday') print("Monday") mean(data.matrix(data[data$weekday=='Monday',"interest"])) ``` Find the mean of the interest variable for the weekends. ```{r} print("Weekends") mean(data.matrix(data[!is.element(data$weekday,weekdays1),"interest"])) ``` Find the mean of the interest variable for all weekdays. ```{r} print("Weekdays") mean(data.matrix(data[is.element(data$weekday,weekdays1),"interest"])) ``` Comment on whether you believe there is a statistically significant difference between the mean interest on weekdays and weekends? You don't have to do a formal test. We're asking for just your intuition after seeing the data. Since your response won't be executable code, do not include it in an r chunk, or if you do, prefix your comments with R's comment character, #. What are the median, minimum, and maximum interest? ```{r} print("Median") median(data$interest) print("Minimum") min(data$interest) print("Maximum") max(data$interest) ``` What is the correlation between interests one day apart? ```{r} first <- c(data[1,"interest"]) second <- c(data[2,"interest"]) first_ <- TRUE for (row in 3:nrow(data)) { if(first_==TRUE){ first_ <- FALSE first <- c(first,data[row,"interest"]) } else{ first_ <- TRUE second <- c(second ,data[row,"interest"]) } } print("Correlation") print(cor(first,second)) ```