-
Notifications
You must be signed in to change notification settings - Fork 0
Plotting Basics
Lucy M Chang edited this page Apr 5, 2018
·
16 revisions
The general formula is y ~ x. This is useful annotation as it is used in the lm() and anova() functions as well.
plot(Sepal.Length ~ Sepal.Width, data = iris)
Use the help file to:
- Make the points triangles rather than circles.
- Make the lines dashed.
- Create a title. Color it blue.
- Add a legend.
- Make a horizontal line
We can add on linear regressions too:
model.iris <- lm(Sepal.Length ~ Sepal.Width, data = iris)
abline(model.iris)
pairs(iris)
Discuss: What is the output of this function?
> hist(iris$Petal.Length)
- Log-transform the histogram
This is where factors come in handy!
boxplot(Petal.Width ~ Species, data = iris)
# reorder so that it the opposite way
iris$Species <- factor(iris$Species, levels = c("virginica", "versicolor", "setosa"))
What is the spread of petal widths per species? What is the median petal width per species?
Day 1 or 2
- Basics of R
- Variables and objects
- Functions and packages
- Conditionals and logical operators
- Practice
- Recap
Day 3
Day 4
Day 5
Extra