-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoin_example.R
More file actions
48 lines (30 loc) · 1.15 KB
/
join_example.R
File metadata and controls
48 lines (30 loc) · 1.15 KB
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
#example of how to utilize data from different sheets on excel file
#By Steve Formel
#Last updated March 12, 2020
library(readxl)
sample_key <- read_excel("GOMRI_R5x2860000002_data.xlsx",
sheet = "sample_key", na = "NA")
infl <- read_excel("data/S5_final_data_4Mar2020.xlsx",
sheet = "inflorescences", na = "NA")
#joining data example----
library(dplyr)
df <- right_join(x = sample_key, y = infl, by = 'sampleID_stem')
#example plot
library(ggplot2)
ggplot(data = df,
aes(x = num_infl,
y = avg_mass_infl)) +
geom_point(aes(color = oil_added)) +
facet_wrap(~ sampling_period)
#Example of how to join multiple data sheets----
pmorph <- read_excel("GOMRI_R5x2860000002_data.xlsx",
sheet = "plant_morphology", na = "NA")
df <- right_join(x = sample_key, y = infl) %>%
right_join(x = pmorph, y = ., by = 'sampleID_stem')
#example plot
library(ggplot2)
ggplot(data = df,
aes(x = num_stems_live,
y = avg_mass_infl)) +
geom_point(aes(color = oil_added)) +
facet_wrap(~ sampling_period)