R Visualization
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)
Output
(Run the program to view its output)
Comments