-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path1_RtutorialChina.Rmd
More file actions
111 lines (82 loc) · 3.64 KB
/
1_RtutorialChina.Rmd
File metadata and controls
111 lines (82 loc) · 3.64 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
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
---
title: "R tutorial China: First steps"
author: "Julia Chacón"
date: "17/2/2020"
output: html_document
---
<style>
p.caption {
font-size: 0.8em;
}
</style>
```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
message = FALSE,
warning = FALSE
)
```
# TRANSPLANT EXPERIMENT GONGGA MOUNTAIN (CHINA)
This is an R tutorial for working with the Transplant Experiment data in Gongga Mountain, China. The purpose of the tutorial is to be able to download the data, read them and understand their structure before playing with them.
## STUDY AND SITE INFORMATION
The transplant study is located in the Gongga Mountains in Sichuan Province, south-west China. The study contains four sites spanning from 3000 to 4130 m a.s.l. along an elevational gradient. The vegetation ranges from coniferous-broadleaved forest to alpine meadows.
```{r echo=FALSE, out.width='60%', fig.cap= "Location of the four study sites along an elevational gradient. Inset indicates the locations of the study sites in China."}
knitr::include_graphics('./map/TransplantMap.png')
```
```{r echo=FALSE, out.width='60%', fig.cap= "Experimental set up for the different warming treatments at each site. Shown are control, local control, OTC, and transplant and arrows indicate direction of transplant"}
knitr::include_graphics('./map/ChinaMountain.jpg')
```
## 1. Install packages
First, is important to install all packages needed. The code in the file "setup.R" will do this and check you have a recent version of R.
## 2. Load the packages
```{r load_packages, eval=TRUE}
library("tidyverse")
library("dataDownloader")
library("DBI")
library("vegan")
library("ggvegan")
library("patchwork")
```
## 3. Download the data
Download the data and store it in the proper files
```{r Download the data, eval=TRUE}
# Instructions to download the Data
# Location of PFTC Data
# The data are located in OSF repository
# To know the exact location of each PFTC Data check this file:
# https://docs.google.com/spreadsheets/d/1y81Xv33BaoWV2FNx0F9XbikjKeHLGNxfmWZ2w4xmISk/edit#gid=0
## COMMUNITY DATA
# China community data from the transplants:
get_file(node = "4hjzu",
file = "transplant.sqlite",
path = "community/data")
## TRAIT DATA
# China traits: Leaf traits
get_file(node = "emzgf",
file = "PFTC1.2_China_2015_2016_LeafTraits.csv",
path = "traits/data")
# China traits: Chemical traits
get_file(node = "emzgf",
file = "PFTC1.2_China_2015_2016_ChemicalTraits.csv",
path = "traits/data")
```
## 4. Read the data
### Cover and composition data
The script to read and process the cover data is in "hidden" folder:
```{r Cover and composition data, eval=TRUE}
source("hidden/start_here.R")
```
This script is going to:
1. Read the data from the transplants (transplant.sqlite)
2. Load cover data and metadata (cover_thin)
3. Make a wide table (cover) with species names in columns and cover values in each plot
4. Make meta data (cover_meta) This are the meta data of the "cover" tibble
We can either source it or run it step by step to see what is doing (preferred option). If you want to run it step by step then open the file.
### Trait data
The traits data are located in China/traits/data, in two files: LeafTraits and ChemicalTraits.
To read the csv files:
```{r Trait data, eval=TRUE}
traitsLeaf <- read_csv(file = "traits/data/PFTC1.2_China_2015_2016_LeafTraits.csv")
traitsChem <- read_csv(file = "traits/data/PFTC1.2_China_2015_2016_ChemicalTraits.csv")
```