-
Notifications
You must be signed in to change notification settings - Fork 7
/
.Rhistory
97 lines (97 loc) · 5.17 KB
/
.Rhistory
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
setwd("C:/Users/mcgregori/Dropbox (Smithsonian)/Github_Ian/SCBI-ForestGEO-Data_private/tree_cores/chronologies/current_chronologies")
core_list <- read.csv("C:/Users/mcgregori/Dropbox (Smithsonian)/Github_Ian/SCBI-ForestGEO-Data/tree_dimensions/tree_crowns/core_list_for_neil.csv")
core_list <- read.csv("C:/Users/mcgregori/Dropbox (Smithsonian)/Github_Ian/tree-growth-and-traits/core_list_for_neil.csv")
#1 which cores used in final chronologies ####
#these cores used in Ryan's paper
setwd("E:/Github_SCBI/SCBI-ForestGEO-Data_private/tree_cores/chronologies/current_chronologies")
chronology_list <- read.csv("E:/Github_SCBI/SCBI-ForestGEO-Data_private/tree_cores/chronologies/chronology_list.csv")
library(stringr)
install.packages("stringr")
library(stringr)
complete <- subset(chronology_list, status=="complete")
View(chronology_list)
complete <- subset(chronology_list, chronology_status=="complete")
chron <- levels(factor(complete$chronology))
chronsp <- str_extract(chron, "[a-z]+")
View(complete)
chron <- levels(factor(complete$chronology_name))
chronsp <- str_extract(chron, "[a-z]+")
file_list <- list.files("E:/Github_SCBI/SCBI-ForestGEO-Data_private/tree_cores/chronologies/current_chronologies/complete", pattern="_drop.csv")
View(chronology_list)
allchron <- read.csv("E:/Github_SCBI/SCBI-ForestGEO-Data_private/tree_cores/cross-dated_cores_CSVformat/all_core_chronologies")
allchron <- read.csv("E:/Github_SCBI/SCBI-ForestGEO-Data_private/tree_cores/cross-dated_cores_CSVformat/all_core_chronologies.csv")
View(allchron)
mergedchron <- subset(allchron, sp %in% chronsp)
chronsp\
chronsp
View(mergedchron)
duplicated(mergedchron$sp)
c <- !duplicated(mergedchron$sp)
c <- !duplicated(mergedchron$sp, values=TRUE)
mergedchron$sp
mergedchron$sp[duplicated(mergedchron$sp),]
mergedchron$sp[duplicated(mergedchron$sp)]
mergedchron$sp[!duplicated(mergedchron$sp)]
c <- mergedchron$sp[!duplicated(mergedchron$sp)]
c\
c
chronsp
d <- allchron$sp[!duplicated(allchron$sp)]
d
View(mergedchron)
"quve" %in% allchron$sp
#2 merging dendro_cored_full with #1, create "dendro_subset_ian_paper.csv" ####
setwd("E:/Github_SCBI/SCBI-ForestGEO-Data/tree_dimensions/tree_crowns")
dendrofull <- read.csv("E:/Github_SCBI/SCBI-ForestGEO-Data/tree_dimensions/tree_crowns/dendro_cored_full.csv")
dendrofull <- read.csv("E:/Github_SCBI/SCBI-ForestGEO-Data/tree_dimensions/tree_crowns/cored_dendroband_crown_position_data/dendro_cored_full.csv")
dendrosub <- merge(dendrofull, mergedchron)
dendrosub <- dendrosub[order(dendrosub[,1]),]
View(dendrosub)
"quve" %in% dendrosub$sp
## make sure there are no duplicates
## this code says give me the tag numbers for the duplicated stemID
dendrosub$tag[duplicated(dendrosub$stemID)]
## for trees that have dbh2018=0, give them dbh2013.
dendrosub$dbh2018 <- ifelse(dendrosub$dbh2018 == 0, dendrosub$dbh2013, dendrosub$dbh2018)
##assume dead trees that have dbh>0 and a crown.position value of CF (AJ couldn't find), have a crown.position of "I" if under 350mm, and C if over 350mm.
dendrosub$crown.position <- as.character(dendrosub$crown.position)
##assume dead trees that have dbh>0 and a crown.position value of CF (AJ couldn't find), have a crown.position of "I" if under 350mm, and C if over 350mm.
dendrosub$crown.position <- NULL
dendrosub$crown.position <- as.character(dendrosub$crown.position)
dendrosub$crown.position <- ifelse(dendrosub$dbh2018>0 &
dendrosub$dbh2018<=350 &
dendrosub$tree.notes == "CF",
"I", dendrosub$crown.position)
library(data.table)
install.packages("data.table")
library(data.table)
dendrosub$crown.position <- as.character(dendrosub$crown.position)
dendrosub$crown.position <- as.character(dendrosub$crown.position)
View(allchron)
allchron <- allchron[,c("tag", "sp")]
mergedchron <- subset(allchron, sp %in% chronsp)
setwd("E:/Github_SCBI/SCBI-ForestGEO-Data/tree_dimensions/tree_crowns")
dendrofull <- read.csv("E:/Github_SCBI/SCBI-ForestGEO-Data/tree_dimensions/tree_crowns/cored_dendroband_crown_position_data/dendro_cored_full.csv")
dendrosub <- merge(dendrofull, mergedchron)
dendrosub <- dendrosub[order(dendrosub[,1]),]
## make sure there are no duplicates
## this code says give me the tag numbers for the duplicated stemID
dendrosub$tag[duplicated(dendrosub$stemID)]
## for trees that have dbh2018=0, give them dbh2013.
dendrosub$dbh2018 <- ifelse(dendrosub$dbh2018 == 0, dendrosub$dbh2013, dendrosub$dbh2018)
##assume dead trees that have dbh>0 and a crown.position value of CF (AJ couldn't find), have a crown.position of "I" if under 350mm, and C if over 350mm.
dendrosub$crown.position <- NULL
dendrosub$crown.position <- as.character(dendrosub$crown.position)
View(mergedchron)
View(dendrosub)
##assume dead trees that have dbh>0 and a crown.position value of CF (AJ couldn't find), have a crown.position of "I" if under 350mm, and C if over 350mm.
dendrosub$crown.position <- NULL
View(dendrosub)
##assume dead trees that have dbh>0 and a crown.position value of CF (AJ couldn't find), have a crown.position of "I" if under 350mm, and C if over 350mm.
dendrosub$crown.position <- ""
dendrosub$crown.position <- as.character(dendrosub$crown.position)
dendrosub$crown.position <- ifelse(dendrosub$dbh2018>0 &
dendrosub$dbh2018<=350 &
dendrosub$tree.notes == "CF",
"I", dendrosub$crown.position)
View(dendrosub)