-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
191 lines (152 loc) · 5.67 KB
/
README.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "75%",
warning = FALSE,
message = FALSE,
fig.align = "center"
)
```
# setariaviridis <a href="https://nononoexe.github.io/setariaviridis/"><img src="man/figures/logo.png" align="right" height="138" alt="setariaviridis website" /></a>
<!-- badges: start -->
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![CRAN status](https://www.r-pkg.org/badges/version/setariaviridis)](https://CRAN.R-project.org/package=setariaviridis)
[![R-CMD-check](https://github.com/NONONOexe/setariaviridis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/NONONOexe/setariaviridis/actions/workflows/R-CMD-check.yaml)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/setariaviridis)](https://cran.r-project.org/package=setariaviridis)
<!-- badges: end -->
## Overview
*Setaria viridis* (green foxtail, ネコジャラシ) is a common weed. This package contains measurements from individual branches of a wild *Setaria viridis* plant collected near the author's home.
The dataset is intended for practicing basic data analysis techniques. It's ideal for learning how to calculate basic descriptive statics, create visualizations such as histograms and scatter plots, and gain experience with data manipulation and exploration using R. Its relatively small size and straightforward structure make this dataset easy to work with for beginners in data analysis.
## Installation
You can install the setariaviridis using the following methods:
### CRAN version
```r
install.packages("setariaviridis")
```
### Development version
#### Using `install.packages()` (R-universe)
```r
# Enable the R-universe
options(repos = c(
nononoexe = "https://nononoexe.r-universe.dev",
cran = "https://cloud.r-project.org"
))
# Install the package
install.packages("setariaviridis")
```
#### Using `pak`
``` r
# install.packages("pak")
pak::pak("NONONOexe/setariaviridis")
```
## About the data
The data in this package comprises measurements of *Setaria viridis* collected by the author around their home in Aichi Prefecture, Japan.
```{r, echo = FALSE}
knitr::include_graphics("man/figures/collect-location.png", dpi = 300)
```
This data was obtained in August 2021 by hand-harvesting Setaria viridis plants, root and all, from a dense population. Measurements of each plant part were taken manually using a tape measure and a ruler.
```{r, echo = FALSE}
knitr::include_graphics("man/figures/collecting-data.png", dpi = 300)
```
The data can be accessed as follows:
```{r showdata}
library(setariaviridis)
data(package = "setariaviridis")
head(setaria_viridis)
```
If you want to see for more info: `?setaria_viridis`
The data contains of 54 branches across 10 *Setaria viridis* plants. *Setaria viridis* consists of 4 parts: panicle, leaf, culm, and root, as illustrated in the figure below:
```{r, echo = FALSE}
knitr::include_graphics("man/figures/setariaviridis-part.png", dpi = 300)
```
Data sharing the same roots can be identified by the `root_number`. For all other measurement items, please refer to the following figure to understand which parts were measured:
```{r, echo = FALSE}
knitr::include_graphics("man/figures/setariaviridis-mesurement.png", dpi = 300)
```
## Example
Using setariaviridis, you can visualize like followings:
```{r culm-hist, echo = FALSE}
library(tidyverse)
# Calculate histogram parameters
hist_params <- lst(
data = setaria_viridis$culm_length,
bin_count = nclass.Sturges(data),
boundary = 16,
bin_width = round(diff(range(data)) / bin_count),
x_min = seq(boundary, max(data), by = bin_width),
x_max = x_min + bin_width,
center = (x_min + x_max) / 2,
labels = str_c(x_min, "-", x_max)
)
# Create histogram plot
culm_hist <-
ggplot(setaria_viridis, aes(x = culm_length)) +
# Add histogram layer with specified parameters
geom_histogram(
binwidth = hist_params$bin_width,
boundary = hist_params$boundary,
colour = "white",
fill = "darkolivegreen4"
) +
# Set plot labels
labs(
title = "Culm length distribution",
x = "Culm length (cm)",
y = "Frequency"
) +
# Customize x-axis scale
scale_x_continuous(
breaks = hist_params$center,
labels = hist_params$labels
) +
# Apply theme customizations
theme_bw() +
theme(
plot.title.position = "plot",
panel.grid = element_blank(),
panel.grid.major.y = element_line(
colour = "black",
linewidth = 0.2
),
axis.ticks.x = element_blank(),
axis.text.x = element_text(
angle = 45,
hjust = 1,
colour = "black",
margin = margin(t = 3, b = 3)
)
)
# Display the histogram
culm_hist
```
```{r panicle-size, echo = FALSE}
# Create scatter plot
panicle_size <-
ggplot(setaria_viridis, aes(x = panicle_width, y = panicle_length)) +
geom_point(colour = "darkolivegreen4") +
labs(
title = "Panicle size",
x = "Panicle width (cm)",
y = "Panicle length (cm)"
) +
theme_bw() +
theme(
plot.title.position = "plot",
panel.grid = element_blank(),
panel.grid.major = element_line(
colour = "black",
linewidth = 0.2,
linetype = "dashed"
)
)
panicle_size
```
## Code of conduct
Please note that this project is released with a [Contributor Code of Conduct](https://nononoexe.github.io/setariaviridis/CODE_OF_CONDUCT.html).
By participating in this project you agree to abide by its terms.