@a_green31

R Visualization

January 26, 2023 · R
library("dplyr")
library("datasets")
library("ggplot2")

cars <- data.frame(mtcars)
head(cars)

# hp qsec

# Create scatterplot of hp v qsec
ggplot(data=mtcars, aes(x=hp, y=qsec)) + geom_point() + geom_smooth(method='lm', se = TRUE) +
ggtitle("Scatterplot of Horsepower v 1/4 mile time") + 
theme(plot.title=element_text(hjust=0.5)) +
xlab("Horsepower (fgs)") + ylab("Quart mile time (sec)")

# Equation for trendline
regression <- lm(qsec~hp, mtcars)
summary(regression)

NHTemp

updated January 19, 2023 · R
library("datasets")
library("dplyr")

first25 <- data.frame(nhtemp[1:25])
last25 <- data.frame(nhtemp[36:60]) 

t_ind <- t.test(first25$nhtemp, last25$nhtemp, alternative="two.sided", var.equal=FALSE)
t_ind

t_dep <- t.test(first25$nhtemp, last25$nhtemp, paired=TRUE)
t_dep