install.packages("devtools")
devtools::install_github("richfitz/datastorr")
devtools::install_github("traitecoevo/baad.data")
#Run the library for the BAAD database
#Retrieve data from the API library
#use the baad function to extract all data
baad_raw <- baad.data::baad_data()
#specify from large list
data_raw <- baad_raw$data
#as well as column dictionaries
dict <- baad_raw$dictionary
data_jpn <- data_raw %>%
filter(str_detect(location, "Japan")) %>%
#remove columns where every value is NAs e.g. all()
select(where(~ !all(is.na(.)
)
)
)
#arrage table and rename cols
clean_jpn <- data_jpn %>%
select(family,
species,
speciesMatched,
pft,
latitude,
longitude,
areatype = vegetation,
dbh = d.bh,
height = h.t,
hdbh = h.bh,
agb = m.so,
rootb = m.rt,
totalb = m.to,
leafarea = a.lf,
leafb = m.lf,
location,
studyName)
#create dictionary for the above
jpn_dict <- dict %>%
filter(variable %in% c("family",
"species",
"speciesMatched",
"pft",
"latitude",
"longitude",
"vegetation",
"d.bh",
"h.t",
"h.bh",
"m.so",
"m.rt",
"m.to",
"a.lf",
"m.lf"))
Data tables above are now japan specific and ready for further transformation and exploratory analysis. For this case, a growth rate/ growth factor was explored using the available age and DBH data.
growthrate <- data_jpn %>%
select(family,
species,
speciesMatched,
dbh = d.bh,
height = h.t,
age,
location,
growingCondition) %>%
filter(!is.na(age), !is.na(dbh), !is.na(height))
Adding the column growingconditions highlights a
possible reason why some tree species of different DBH and height have
the relative same age. PM is classified as plantation
managed which means all currents trees might have been replanted at the
same time.
To find the growth factor a simple equations is used
DBH = growthfactor x age
Therefore the growthfactor should be determined using DBH/age in this simplistic method.
growthrate_spp <- growthrate %>%
#divide the dbh (in cm) by age
mutate(gf = (dbh * 100 ) / age) %>%
#group the new growthfators by species that match
group_by(species) %>%
#find the overall averag by gf
summarise(avg_gf_cmyr = mean(gf), n = n())