-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheds212-day2-comp2.qmd
47 lines (37 loc) · 1.02 KB
/
eds212-day2-comp2.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: "eds212-day2-comp2"
format: html
editor: visual
---
```{r}
# attach already installed packages
library(tidyverse)
library(palmerpenguins)
```
## Plotting functions in ggplot2
```{r}
fx = function(x) {3 * x ^ 2 + 4}
# c means concatonate, makes a vector
# ggplot always wants a dataframe of values
# geom_function uses the s of 1 and 100 as end points and calculates the height of the function at all points in btw
ggplot(data = data.frame(x = c(1, 100)), aes( x = x)) + geom_function(fun = fx)
```
## Partial Derivative
```{r}
fxyz = expression(2 * x * y + 3 * (x ^ 2) * ( Z ^ 3))
dfdy = D(fxyz, 'y')
dfdy
```
## Penguins plot
```{r}
# aes is for mapping variables onto chart aesthetics (ex. coloring by species)
ggplot() +
geom_point(data = penguins,
aes(x = flipper_length_mm,
y = body_mass_g,
color = species)) +
labs(x = "Flipper Length (mm)",
y = "Body Mass (g)",
title = "Palmer penguins body dimensions") +
theme_minimal()
```