Skip to content

Commit

Permalink
posting eda notes
Browse files Browse the repository at this point in the history
  • Loading branch information
aloy committed Jan 4, 2017
1 parent 942e02a commit d603414
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions lec02/.Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
mpg <- read.csv(file = "https://github.com/math430-lu/data/raw/master/mpg.csv", as.is = TRUE)
library(ggplot2)
mpg <- read.csv(file = "https://github.com/math430-lu/data/raw/master/mpg.csv")
library(ggplot2)
dim(mpg)
head(mpg)
ggplot(data = mpg, mapping = aes(x = weight, y = mpg)) +
geom_point()
ggplot(data = mpg, mapping = aes(x = weight, y = mpg)) +
geom_point() +
labs(x = "weight (lbs.)", y = "fuel economy (mpg)")
cor(mpg$weight, mpg$mpg)
x <- -5:5
y <- x^2
cor(x, y)
ggplot(data = data.frame(x, y), mapping = aes(x, y)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE)
qplot(x3, y3, data = anscombe) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.816", x = 6, y = 12, size = 6)
qplot(x3, y3, data = filter(anscombe, y3 < 9)) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.999", x = 6, y = 12, size = 6)
qplot(x3, y3, data = anscombe) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.816", x = 6, y = 12, size = 6)
qplot(x3, y3, data = subset(anscombe, y3 < 9)) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.999", x = 6, y = 12, size = 6)
grid.arrange(p1, p2, nrow = 1)
qplot(x3, y3, data = anscombe) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.816", x = 6, y = 12, size = 6)
qplot(x3, y3, data = subset(anscombe, y3 < 9)) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.999", x = 6, y = 12, size = 6)
library(gridExtra)
p1 <- qplot(x3, y3, data = anscombe) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.816", x = 6, y = 12, size = 6)
p2 <- qplot(x3, y3, data = subset(anscombe, y3 < 9)) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.999", x = 6, y = 12, size = 6)
grid.arrange(p1, p2, nrow = 1)
1:10
# You will need to load the package in each R markdown notebook
library(tidyverse)
# Load the data and assign it a name
mpg <- read.csv("https://github.com/math430-lu/data/raw/master/mpg.csv")
# Printing the first 6 rows
# Note that missing values are denoted by NA
head(mpg)
# Printing the last 6 rows
tail(mpg)
# Looking at the number of rows and columns
dim(mpg)
# Looking at the structure
str(mpg)
# Getting a glimpse of the structure
glimpse(mpg)
# looking at the summary
summary(mpg)
ggplot(data = mpg, mapping = aes(x = weight, y = mpg)) +
geom_point() +
labs(x = "weight (lbs.)", y = "fuel economy (mpg)")
cor(mpg$weight, mpg$mpg)
x <- -5:5
y <- x^2
cor(x, y)
ggplot(data = data.frame(x, y), mapping = aes(x, y)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE)
library(gridExtra)
p1 <- qplot(x3, y3, data = anscombe) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.816", x = 6, y = 12, size = 6)
p2 <- qplot(x3, y3, data = subset(anscombe, y3 < 9)) +
xlab("x") + ylab("y") + scale_y_continuous(limits=c(5,13)) +
annotate("text", label = "r = 0.999", x = 6, y = 12, size = 6)
grid.arrange(p1, p2, nrow = 1)

0 comments on commit d603414

Please sign in to comment.