knitr::opts_chunk$set(echo = FALSE,message=FALSE,warning=FALSE, fig.width = 8,fig.height=8) # Correlation matrix to look at Pli data library(tidyverse) # library(dplR)6. # library(corrplot) # source("http://www.sthda.com/upload/rquery_cormat.r") load("~/Documents/Git/pliDrought2019/data/pliDat.RData")
The dataset of Pli ring data contains the following columns:
# Correlation matrix x<- pliDat$ringData %>% filter(Type=="lw") %>% filter(Tree.Num==2) %>% # filter for live trees mutate(coreID=paste(Opening,coreID,sep="-")) %>% dplyr::select(coreID,Year,Value) %>% pivot_wider(names_from=coreID,values_from=Value) %>% filter(Year>=1990) %>% column_to_rownames("Year") # detrend(method="Spline")
plotAdjTrees<-function(site,ringVar="rw") { # come up with list to remove trees that lack a pair plotList<- pliDat$ringData %>% filter(Opening==site) %>% filter(Type==ringVar) %>% group_by(Plot) %>% distinct(Tree.Num) %>% group_by(Plot) %>% summarise(Num.Trees=n()) %>% filter(Num.Trees==2) %>% pull(Plot) pliDat$ringData %>% filter(Opening==site) %>% filter(Type==ringVar) %>% filter(Plot %in% plotList) %>% mutate(Plot=paste("Plot",":",Plot,sep="")) %>% mutate(Tree.Num=fct_recode(Tree.Num,Dead="1",Live="2")) %>% rename(Tree=Tree.Num) %>% filter(Year>=2000) %>% ggplot()+ aes(x=Year,y=Value,color=Tree,group=Tree)+ geom_point()+ geom_line()+ facet_wrap(~Plot,ncol=2)+ theme(legend.position="bottom", axis.text.x = element_text(angle = 270, vjust = 0.5, hjust=1))+ scale_x_continuous(limits=c(2000,2018),breaks=seq(from=2000,to=2018,by=2), # minor_breaks = seq(from=2000,to=2018,by=2), name="Year") }
Let's compare annual variables between paired trees in Site r site2="264";site2
.
plotAdjTrees(site=site2,ringVar="rw")+ ylab("Annual ring width (mm)")
\newpage
plotAdjTrees(site="264",ringVar="rwd")+ ylab("Mean ring density (g/cm3)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.