Last updated: 2021-09-13

Checks: 7 0

Knit directory: soil_alcontar/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20210907) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 259a5fc. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/C369E4F4/
    Ignored:    .Rproj.user/shared/notebooks/0EF54E14-NOBORRAR/
    Ignored:    .Rproj.user/shared/notebooks/33E25F73-analysis_resilience/
    Ignored:    .Rproj.user/shared/notebooks/3F603CAC-map/
    Ignored:    .Rproj.user/shared/notebooks/4A68381F-general_overview_soils/
    Ignored:    .Rproj.user/shared/notebooks/4E13660A-temporal_comparison/
    Ignored:    .Rproj.user/shared/notebooks/827D0727-analysis_pre_post/
    Ignored:    .Rproj.user/shared/notebooks/A3F813C2-index/
    Ignored:    .Rproj.user/shared/notebooks/D4E3AA10-analysis_zona_time/

Untracked files:
    Untracked:  analysis/NOBORRAR.Rmd
    Untracked:  analysis/analysis_pre_post_cache/
    Untracked:  analysis/test.Rmd
    Untracked:  data/spatial/01_EP_ANDALUCIA/EP_Andalucía.shp.DESKTOP-CKNNEUJ.5492.5304.sr.lock
    Untracked:  data/spatial/lucdeme/
    Untracked:  data/spatial/parcelas/GEO_PARCELAS.shp.DESKTOP-CKNNEUJ.5492.5304.sr.lock
    Untracked:  map.Rmd
    Untracked:  output/anovas_pre_post.csv
    Untracked:  output/anovas_zona_time.csv

Unstaged changes:
    Modified:   data/Resultados_Suelos_2018_2021_v2.xlsx
    Modified:   data/spatial/.DS_Store
    Modified:   data/spatial/01_EP_ANDALUCIA/EP_Andalucía.dbf
    Deleted:    index.Rmd
    Modified:   scripts/00_prepare_data.R
    Modified:   temporal_comparison.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/analysis_resilience.Rmd) and HTML (docs/analysis_resilience.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 259a5fc ajpelu 2021-09-13 add plots of resilience

Introduction

  • Analysis of resilience of soil propierties.
  • Only for Autumn treatment (i.e. zona == “P”; zona == “NP”)
  • Interpret zona as “grazing effect”:
    • zona == “P” corresponds to Browsing
    • zona == “NP” corresponds to No Browsing

Prepare data

raw_soil <- readxl::read_excel(here::here("data/Resultados_Suelos_2018_2021_v2.xlsx"), 
    sheet = "SEGUIMIENTO_SUELOS_sin_ouliers") %>% janitor::clean_names() %>% mutate(treatment_name = case_when(str_detect(geo_parcela_nombre, 
    "NP_") ~ "Autumn Burning / No Browsing", str_detect(geo_parcela_nombre, "PR_") ~ 
    "Spring Burning / Browsing", str_detect(geo_parcela_nombre, "P_") ~ "Autumn Burning / Browsing"), 
    zona = case_when(str_detect(geo_parcela_nombre, "NP_") ~ "QOt_NP", str_detect(geo_parcela_nombre, 
        "PR_") ~ "QPr_P", str_detect(geo_parcela_nombre, "P_") ~ "QOt_P"), fecha = lubridate::ymd(fecha), 
    pre_post_quema = case_when(pre_post_quema == "Prequema" ~ "0 preQuema", pre_post_quema == 
        "Postquema" ~ "1 postQuema"))
  • Compute date as months after fire
autumn_fire <- lubridate::ymd("2018-12-18")

soil <- raw_soil %>% filter(zona != "QPr_P") %>% mutate(zona = as.factor(zona)) %>% 
    mutate(meses = as.factor(case_when(fecha == "2018-12-11" ~ as.character("-1"), 
        fecha != "2018-12-11" ~ as.character(lubridate::interval(autumn_fire, lubridate::ymd(fecha))%/%months(1))))) %>% 
    mutate(pastoreo = as.factor(case_when(zona == "QOt_P" ~ "Browsing", zona == "QOt_NP" ~ 
        "No Browsing"))) %>% relocate(pastoreo, fecha, meses) %>% dplyr::select(-pre_post_quema, 
    -tratamiento)

xtabs(~meses + pastoreo, data = soil)
     pastoreo
meses Browsing No Browsing
   -1       24          24
   0        24          24
   22       25          25
   29       24          24

Compute resilience

For each soil variable we compute the Resilience value according to the following equation (sensu LLoret et al. 2011): \[Resilience = preFire / postFire\] - We computed the resilience value for each time step: just after fire (month=0) and after 22 and 29 months.

  • The we groupped soil variables by treatment (Browsing vs No Browsing)

  • Finally we explored graphically the results.

computeResilience <- function(df, variable) {
    df %>% mutate(replica = str_remove(geo_suelos_nombre, "Q|_Q")) %>% dplyr::select(one_of("pastoreo", 
        "meses", "geo_parcela_nombre", "replica", variable)) %>% pivot_wider(values_from = one_of(variable), 
        names_from = meses, names_prefix = "t") %>% filter(!(str_detect(replica, 
        "E3"))) %>% rename(control = `t-1`) %>% # resilience r = post/pre
    mutate(res.0 = t0/control, res.22 = t22/control, res.29 = t29/control) %>% dplyr::select(pastoreo, 
        geo_parcela_nombre, res.0, res.22, res.29) %>% pivot_longer(res.0:res.29, 
        names_to = "resilience") %>% mutate(myvar = variable)
}


x <- bind_rows(computeResilience(soil, "humedad"), computeResilience(soil, "n_nh4"), 
    computeResilience(soil, "n_no3"), computeResilience(soil, "fe_percent"), computeResilience(soil, 
        "k_percent"), computeResilience(soil, "mg_percent"), computeResilience(soil, 
        "na_percent"), computeResilience(soil, "n_percent"), computeResilience(soil, 
        "c_percent"), computeResilience(soil, "c_n"), computeResilience(soil, "cic"), 
    computeResilience(soil, "p"), computeResilience(soil, "mo"), computeResilience(soil, 
        "p_h_agua_eez"), computeResilience(soil, "p_h_k_cl"))


x <- x %>% mutate(meses = str_remove(resilience, "res."))

Plots


R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.3

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] car_3.0-10         carData_3.0-4      glmmADMB_0.8.3.3   glmmTMB_1.0.2.1   
 [5] DHARMa_0.3.3.0     afex_0.28-1        performance_0.7.2  multcomp_1.4-16   
 [9] TH.data_1.0-10     mvtnorm_1.1-1      emmeans_1.5.4      lmerTest_3.1-3    
[13] lme4_1.1-27.1      Matrix_1.3-2       fitdistrplus_1.1-3 survival_3.2-7    
[17] MASS_7.3-53        ggpubr_0.4.0       janitor_2.1.0      here_1.0.1        
[21] forcats_0.5.1      stringr_1.4.0      dplyr_1.0.6        purrr_0.3.4       
[25] readr_1.4.0        tidyr_1.1.3        tibble_3.1.2       ggplot2_3.3.5     
[29] tidyverse_1.3.1    rmdformats_1.0.1   knitr_1.31         workflowr_1.6.2   

loaded via a namespace (and not attached):
 [1] minqa_1.2.4         colorspace_2.0-0    ggsignif_0.6.0     
 [4] ellipsis_0.3.2      rio_0.5.16          rprojroot_2.0.2    
 [7] estimability_1.3    snakecase_0.11.0    fs_1.5.0           
[10] rstudioapi_0.13     farver_2.0.3        fansi_0.4.2        
[13] lubridate_1.7.10    xml2_1.3.2          codetools_0.2-18   
[16] splines_4.0.2       jsonlite_1.7.2      nloptr_1.2.2.2     
[19] broom_0.7.9         dbplyr_2.1.1        compiler_4.0.2     
[22] httr_1.4.2          backports_1.2.1     assertthat_0.2.1   
[25] fastmap_1.1.0       cli_2.5.0           formatR_1.8        
[28] later_1.1.0.1       htmltools_0.5.2     tools_4.0.2        
[31] coda_0.19-4         gtable_0.3.0        glue_1.4.2         
[34] reshape2_1.4.4      Rcpp_1.0.7          cellranger_1.1.0   
[37] jquerylib_0.1.3     vctrs_0.3.8         nlme_3.1-152       
[40] iterators_1.0.13    insight_0.14.4      xfun_0.23          
[43] openxlsx_4.2.3      rvest_1.0.0         lifecycle_1.0.0    
[46] rstatix_0.6.0       zoo_1.8-8           scales_1.1.1       
[49] hms_1.0.0           promises_1.2.0.1    parallel_4.0.2     
[52] sandwich_3.0-0      TMB_1.7.19          yaml_2.2.1         
[55] curl_4.3            sass_0.3.1          stringi_1.7.4      
[58] highr_0.8           foreach_1.5.1       boot_1.3-26        
[61] zip_2.1.1           R2admb_0.7.16.2     rlang_0.4.10       
[64] pkgconfig_2.0.3     evaluate_0.14       lattice_0.20-41    
[67] labeling_0.4.2      tidyselect_1.1.1    plyr_1.8.6         
[70] magrittr_2.0.1      bookdown_0.21.6     R6_2.5.0           
[73] generics_0.1.0      DBI_1.1.1           pillar_1.6.1       
[76] haven_2.3.1         whisker_0.4         foreign_0.8-81     
[79] withr_2.4.1         abind_1.4-5         modelr_0.1.8       
[82] crayon_1.4.1        utf8_1.1.4          rmarkdown_2.8      
[85] grid_4.0.2          readxl_1.3.1        data.table_1.14.0  
[88] git2r_0.28.0        reprex_2.0.0        digest_0.6.27      
[91] xtable_1.8-4        httpuv_1.5.5        numDeriv_2016.8-1.1
[94] munsell_0.5.0       bslib_0.2.4