-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCorrelation Analysis.R
36 lines (32 loc) · 1.39 KB
/
Correlation Analysis.R
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
library(car)
library(corrplot)
library(tidyverse)
c <- read.csv("carbon_data_biserial.csv")
y <- read.csv("yield_data_biserial.csv")
### changed categorical data into biserial data
# compost_added: yes = 1, no = 0
# winter_cover_freq: Every 4th winter = 1, Every winter = 4
# cover_crop_type: Rye = 1, Leg-rye = 2, Mustard = 3
# cover_crop_seeding_rate: 1x = 1, 3x = 3
# correlation plot
corr_val_c <- cor(c, method = "spearman")
corrplot(corr_val_c, method = "number", type = "upper")
corr_val_y <- cor(y, method = "spearman")
corrplot(corr_val_y, method = "number", type = "upper")
# boxplot - using originial categorical data
boxplot(TOC_mg_ha ~ compost_added, data = c)
c %>% kruskal.test(TOC_mg_ha ~ compost_added)
boxplot(TOC_mg_ha ~ winter_cover_freq, data = c)
c %>% kruskal.test(TOC_mg_ha ~ winter_cover_freq)
boxplot(TOC_mg_ha ~ cover_crop_type, data = c)
c %>% kruskal.test(TOC_mg_ha ~ cover_crop_type)
boxplot(TOC_mg_ha ~ cover_crop_seeding_rate, data = c)
c %>% kruskal.test(TOC_mg_ha ~ cover_crop_seeding_rate)
boxplot(TON_ma_ha ~ compost_added, data = c)
y %>% kruskal.test(TOC_mg_ha ~ compost_added)
boxplot(TON_ma_ha ~ winter_cover_freq, data = c)
y %>% kruskal.test(TOC_mg_ha ~ winter_cover_freq)
boxplot(TON_ma_ha ~ cover_crop_type, data = c)
y %>% kruskal.test(TOC_mg_ha ~ cover_crop_type)
boxplot(TON_ma_ha ~ cover_crop_seeding_rate, data = c)
y %>% kruskal.test(TOC_mg_ha ~ cover_crop_seeding_rate)