Skip to content

Commit

Permalink
Added some ggplot to the lectures
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaffo committed Sep 4, 2014
1 parent ee42232 commit 3e5b14b
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 154 deletions.
2 changes: 2 additions & 0 deletions 07_RegressionModels/01_04_rttm/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ g = g + geom_hline(yintercept = 0)
g = g + geom_abline(position = "identity")
g = g + geom_abline(intercept = 0, slope = rho, size = 2)
g = g + geom_abline(intercept = 0, slope = 1 / rho, size = 2)
g = g + xlab("Father's height, normalized")
g = g + ylab("Son's height, normalized")
g
```

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 19 additions & 13 deletions 07_RegressionModels/01_05_linearRegression/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ framework : io2012 # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js # {highlight.js, prettify, highlight}
hitheme : tomorrow #
url:
lib: ../../libraries
lib: ../../librariesNew
assets: ../../assets
widgets : [mathjax] # {mathjax, quiz, bootstrap}
mode : selfcontained # {standalone, draft}
Expand Down Expand Up @@ -114,24 +114,30 @@ in carats (standard measure of diamond mass, 0.2 $g$). To get the data use `libr
Plotting the fitted regression line and data
```
data(diamond)
plot(diamond$carat, diamond$price,
xlab = "Mass (carats)",
ylab = "Price (SIN $)",
bg = "lightblue",
col = "black", cex = 1.1, pch = 21,frame = FALSE)
abline(lm(price ~ carat, data = diamond), lwd = 2)
library(ggplot2)
g = ggplot(diamond, aes(x = carat, y = price),
)
g = g + xlab("Mass (carats)")
g = g + ylab("Pice (SIN $)")
g = g + geom_point(size = 6, colour = "black", alpha=0.2)
g = g + geom_point(size = 5, colour = "blue", alpha=0.2)
g = g + geom_smooth(method = "lm", colour = "black")
g
```

---
## The plot
```{r, echo = FALSE, fig.height=5,fig.width=5}
data(diamond)
plot(diamond$carat, diamond$price,
xlab = "Mass (carats)",
ylab = "Price (SIN $)",
bg = "lightblue",
col = "black", cex = 1.1, pch = 21,frame = FALSE)
abline(lm(price ~ carat, data = diamond), lwd = 2)
library(ggplot2)
g = ggplot(diamond, aes(x = carat, y = price),
)
g = g + xlab("Mass (carats)")
g = g + ylab("Pice (SIN $)")
g = g + geom_point(size = 6, colour = "black", alpha=0.2)
g = g + geom_point(size = 5, colour = "blue", alpha=0.2)
g = g + geom_smooth(method = "lm", colour = "black")
g
```

---
Expand Down
Loading

0 comments on commit 3e5b14b

Please sign in to comment.