-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathtutorial-code-12-14-22.Rmd
108 lines (86 loc) · 1.89 KB
/
tutorial-code-12-14-22.Rmd
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
title: "TOG Tutorial December 14"
author: "William Casazza"
date: "14/12/2022"
output:
html_document:
toc: yes
df_print: default
number_sections: yes
keep_md: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,fig.width=8)
```
# Our first our script in Rmarkdown
```{r}
print("hello world")
```
# Step 1: Load libraries
```{r}
# install.packages("knitr")
library(knitr)
library(dplyr)
library(ggplot2)
library(here)
i_am("tutorial-code-12-14-22.Rmd")
```
# Step 2: load data
```{r}
data("iris")
attach(iris)
iris <- iris
str(iris)
head(iris)
tail(iris)
summary(iris)
```
![](iris_image.png)
```{r}
iris %>%
group_by(Species) %>% #group data by species
summarize(mean.length = mean(Sepal.Length),
mean.width = mean(Sepal.Width))
ggplot(iris, aes(x=Sepal.Length, y= Sepal.Width, color=Species))+ #what data
geom_point() #how to visualize data
```
```{r}
iris %>%
group_by(Species) %>%
summarize(mean.length = mean(Petal.Length),
mean.width = mean(Petal.Width))
#plot
ggplot(iris, aes(x = Petal.Length, y = Petal.Width, col = Species)) +
geom_point()
```
```{r}
iris
```
# Part 3: printing pretty tables with kable
```{r}
summary(iris)
kable(summary(iris),caption= "summary of iris data")
```
# Part 4: code chunk options
```{r,eval=FALSE}
ggplot(iris, aes(x = Petal.Length, y = Petal.Width, col = Species)) +
geom_point()
```
```{r,fig.height=2,fig.width=2}
ggplot(iris, aes(x = Petal.Length, y = Petal.Width, col = Species)) +
geom_point()
```
# Part 5: Taking notes
I'm now reporting the standard deviation of the petal width for setosa iris as: `r sd(iris[iris$Species == "setosa","Petal.Width"])`.
How am I organizing this document:
* Set-up
* load library
* load data
* second example
+ first item
- second item
* third item
Numbered steps:
1. step 1
1. Step 2
Format text *bold* **italicize**