Commit 2354e5ed authored by Boulangeat Isabelle's avatar Boulangeat Isabelle
Browse files

new figs

parent 17ce3da7
......@@ -19,10 +19,26 @@ knitr::opts_chunk$set(echo = TRUE)
library(tidyr)
sapply(list.files("R_fct"), function(x)source(paste0("R_fct/",x)))
data = readRDS("data.rds")
data$otable[which(is.na(data$otable$hauteur)),]
dat_h_veg = unique(merge(data$h, data$sites[,c("id_site", "ref_typoveg")], by.x = "ref_site", by.y ="id_site"))
length(unique(dat_h_veg$releve))
dim(dat_h_veg)
summary(dat_h_veg$hmean)
#==============================
library(dplyr)
# library(reshape)
library(tidyr)
library(ggplot2)
```
```{r ,fig=TRUE}
dat_h_veg = merge(data$h, data$sites[,c("id_site", "ref_typoveg")], by.x = "ref_site", by.y ="id_site")
library(dplyr)
library(tidyr)
......@@ -37,6 +53,82 @@ dat_long <- dat_h_veg %>%
ggplot(dat_long, aes(fill=stat, x=ref_typoveg, y=value)) +
geom_bar(position = "dodge", stat = "identity") +
facet_wrap(~stat, ncol = 1, scales = "free")
```
```{r ,fig=TRUE}
## boxplot par milieu ##
ggplot(dat_h_veg, aes(x = reorder(ref_typoveg, hmean, na.rm=TRUE), y = hmean)) +
geom_boxplot() +
labs(y="Hauteur moyenne (est. biomasse)", x="Type vegetation")
```
```{r ,fig=TRUE}
## H series par milieu ##
pl <- ggplot(dat_h_veg, aes(x = date_releve, y = hmean)) +
geom_line(aes(color = ref_site), show.legend = FALSE) +
facet_wrap(~ref_typoveg)
pl + theme(legend.position = "none")
```
```{r ,fig=TRUE}
calage = read.csv("../PNE_calage_reformat.csv", sep= ";", dec = ",")
head(calage)
str(calage)
calage$releve = paste0(calage$site, calage$Releveur)
cal_mean = unique(calage %>% group_by(releve) %>% summarize(site = site, hmean = mean(hauteur, na.rm=TRUE)))
ggplot(cal_mean, aes(x = reorder(site, hmean), y = hmean)) +
geom_boxplot() +
geom_point()
obs_error = cal_mean %>% group_by(site) %>% summarize(hmad = mad(hmean), hmad_st = mad(hmean)/mean(hmean), hm = mean(hmean))
```
```{r ,fig=TRUE}
ggplot(obs_error, aes(x = reorder(site, hm), y = hmad_st)) +
geom_bar(stat = "identity")
```
```{r ,fig=TRUE}
### sd vs mad
ggplot(dat_h_veg, aes(x = hmad, y = hsd)) +
geom_point()
```
```{r ,fig=TRUE}
### dans le temps
ggplot(dat_h_veg, aes(x = date_releve, y = hmad)) +
geom_line(aes(color = ref_site), show.legend = FALSE) +
facet_wrap(~ref_typoveg)
## boxplot par milieu ##
```
```{r ,fig=TRUE}
ggplot(dat_h_veg, aes(x = reorder(ref_typoveg, hmad, na.rm=TRUE), y = hmad)) +
geom_boxplot() +
labs(y="Variation intra de hauteur", x="Type vegetation")
```
```{r ,fig=TRUE}
ggplot(dat_h_veg, aes(x = reorder(ref_typoveg, hmad/hmean, na.rm=TRUE), y = hmad/hmean)) +
geom_boxplot() +
labs(y="Variation intra de hauteur (stand. moy.)", x="Type vegetation")
```
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -15,79 +15,177 @@ always_allow_html: true
```r
dat_h_veg = merge(data$h, data$sites[,c("id_site", "ref_typoveg")], by.x = "ref_site", by.y ="id_site")
str(dat_h_veg)
library(dplyr)
library(tidyr)
library(ggplot2)
dat_long <- dat_h_veg %>%
select(hmean, hmad, ref_typoveg) %>%
drop_na() %>%
group_by(ref_typoveg) %>%
summarize(hauteur=mean(hmean), var_inter=mad(hmean), var_intra = mean(hmad)) %>%
gather(stat, value, hauteur:var_intra)
```
```
## 'data.frame': 1368 obs. of 8 variables:
## $ ref_site : chr "BELRIV01" "BELRIV01" "BELRIV01" "BELRIV01" ...
## $ ref_releve : chr "BELRIV01_L1_18_09_2019" "BELRIV01_L1_07_08_2017" "BELRIV01_L1_14_06_2017" "BELRIV01_L2_23_07_2019" ...
## $ hmean : num 6.4 7.55 10.11 8.96 6.79 ...
## $ hsd : num 5.09 5.75 5.86 6.17 4.48 ...
## $ hmad : num 5.93 5.93 5.56 7.78 4.45 ...
## $ date_releve : Date, format: "2019-09-18" "2017-08-07" ...
## $ ref_observateur: chr "IRS_CT" "IRS_GL" "IRS_GL" "IRS_CT" ...
## $ ref_typoveg : chr "QUE" "QUE" "QUE" "QUE" ...
## `summarise()` ungrouping output (override with `.groups` argument)
```
```r
summary(dat_h_veg$hmean)
ggplot(dat_long, aes(fill=stat, x=ref_typoveg, y=value)) +
geom_bar(position = "dodge", stat = "identity") +
facet_wrap(~stat, ncol = 1, scales = "free")
```
![](README_files/figure-html/unnamed-chunk-1-1.png)<!-- -->
```r
## boxplot par milieu ##
ggplot(dat_h_veg, aes(x = reorder(ref_typoveg, hmean, na.rm=TRUE), y = hmean)) +
geom_boxplot() +
labs(y="Hauteur moyenne (est. biomasse)", x="Type vegetation")
```
```
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.500 3.872 6.319 8.394 10.581 45.675 160
## Warning: Removed 145 rows containing non-finite values (stat_boxplot).
```
![](README_files/figure-html/unnamed-chunk-2-1.png)<!-- -->
```r
#==============================
## H variation par milieu ##
#===============================
## H series par milieu ##
library(dplyr)
pl <- ggplot(dat_h_veg, aes(x = date_releve, y = hmean)) +
geom_line(aes(color = ref_site), show.legend = FALSE) +
facet_wrap(~ref_typoveg)
pl + theme(legend.position = "none")
```
```
##
## Attaching package: 'dplyr'
## Warning: Removed 135 row(s) containing missing values (geom_path).
```
![](README_files/figure-html/unnamed-chunk-3-1.png)<!-- -->
```r
calage = read.csv("../PNE_calage_reformat.csv", sep= ";", dec = ",")
head(calage)
```
## The following objects are masked from 'package:stats':
##
## filter, lag
```
## X...point hauteur date Releveur site
## 1 1 20 5/6/14 Clotilde Sagot ORN-1
## 2 2 10 5/6/14 Clotilde Sagot ORN-1
## 3 3 25 5/6/14 Clotilde Sagot ORN-1
## 4 4 23 5/6/14 Clotilde Sagot ORN-1
## 5 5 14 5/6/14 Clotilde Sagot ORN-1
## 6 6 24 5/6/14 Clotilde Sagot ORN-1
```
```r
str(calage)
```
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
```
## 'data.frame': 1680 obs. of 5 variables:
## $ X...point: int 1 2 3 4 5 6 7 8 9 10 ...
## $ hauteur : num 20 10 25 23 14 24 14.5 22 8 26 ...
## $ date : chr "5/6/14" "5/6/14" "5/6/14" "5/6/14" ...
## $ Releveur : chr "Clotilde Sagot" "Clotilde Sagot" "Clotilde Sagot" "Clotilde Sagot" ...
## $ site : chr "ORN-1" "ORN-1" "ORN-1" "ORN-1" ...
```
```r
# library(reshape)
library(tidyr)
library(ggplot2)
dat_long <- dat_h_veg %>%
select(hmean, hmad, ref_typoveg) %>%
drop_na() %>%
group_by(ref_typoveg) %>%
summarize(hauteur=mean(hmean), var_inter=mad(hmean), var_intra = mean(hmad)) %>%
gather(stat, value, hauteur:var_intra)
calage$releve = paste0(calage$site, calage$Releveur)
cal_mean = unique(calage %>% group_by(releve) %>% summarize(site = site, hmean = mean(hauteur, na.rm=TRUE)))
```
```
## `summarise()` regrouping output by 'releve' (override with `.groups` argument)
```
```r
ggplot(cal_mean, aes(x = reorder(site, hmean), y = hmean)) +
geom_boxplot() +
geom_point()
```
![](README_files/figure-html/unnamed-chunk-4-1.png)<!-- -->
```r
obs_error = cal_mean %>% group_by(site) %>% summarize(hmad = mad(hmean), hmad_st = mad(hmean)/mean(hmean), hm = mean(hmean))
```
```
## `summarise()` ungrouping output (override with `.groups` argument)
```
```r
ggplot(dat_long, aes(fill=stat, x=ref_typoveg, y=value)) +
geom_bar(position = "dodge", stat = "identity") +
facet_wrap(~stat, ncol = 1, scales = "free")
ggplot(obs_error, aes(x = reorder(site, hm), y = hmad_st)) +
geom_bar(stat = "identity")
```
![](README_files/figure-html/unnamed-chunk-1-1.png)<!-- -->
![](README_files/figure-html/unnamed-chunk-5-1.png)<!-- -->
```r
### sd vs mad
ggplot(dat_h_veg, aes(x = hmad, y = hsd)) +
geom_point()
```
```
## Warning: Removed 145 rows containing missing values (geom_point).
```
![](README_files/figure-html/unnamed-chunk-6-1.png)<!-- -->
```r
### dans le temps
ggplot(dat_h_veg, aes(x = date_releve, y = hmad)) +
geom_line(aes(color = ref_site), show.legend = FALSE) +
facet_wrap(~ref_typoveg)
```
```
## Warning: Removed 135 row(s) containing missing values (geom_path).
```
![](README_files/figure-html/unnamed-chunk-7-1.png)<!-- -->
```r
## boxplot par milieu ##
```
```r
ggplot(dat_h_veg, aes(x = reorder(ref_typoveg, hmad, na.rm=TRUE), y = hmad)) +
geom_boxplot() +
labs(y="Variation intra de hauteur", x="Type vegetation")
```
```
## Warning: Removed 145 rows containing non-finite values (stat_boxplot).
```
![](README_files/figure-html/unnamed-chunk-8-1.png)<!-- -->
```r
ggplot(dat_h_veg, aes(x = reorder(ref_typoveg, hmad/hmean, na.rm=TRUE), y = hmad/hmean)) +
geom_boxplot() +
labs(y="Variation intra de hauteur (stand. moy.)", x="Type vegetation")
```
```
## Warning: Removed 145 rows containing non-finite values (stat_boxplot).
```
![](README_files/figure-html/unnamed-chunk-9-1.png)<!-- -->
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment