# NOT RUN {
##Define deposition rate
binborder=1:6 #temporal bins for the deposition rate
depoval=c(5,4,3,1,2) #deposition rate in the bins
#plot deposition rate
depositionrate=approxfun(binborder,c(depoval,tail(depoval,1)),method="constant",yleft=NA,yright=NA)
plot(depositionrate(seq(from=min(binborder),to=max(binborder),length.out=100)),xlab='time',
ylab='deposition rate', main='Deposition rate')
##at what stratigraphic height can an object be found that was deposited in the
##sediment after 5 time units?
timetostratpointbin(5,binborder,depoval)
##create age model
#points that will be transformed into stratigraphic height
time=seq(from=min(binborder),to=max(binborder),length.out=100)
reslist=timetostratpointbin(time,binborder,depoval)
#plot age model
plot(reslist$height,reslist$age,type='l',ylab='Time',xlab='Stratigraphic Height',main='Age model')
## Age model with removal of sediment (hiatus)
depoval=c(5,4,-3,1,2) #in the midle time bin, erosion rate is 3
reslist=timetostratpointbin(time,binborder,depoval)
#plot age model. the gap represents the hiatus
plot(reslist$height,reslist$age,type='l',ylab='Time',xlab='Stratigraphic Height',
main='Age model with erosion')
#A object deposited in the sediment after 3.5 time units is destroyed due to the hiatus:
timetostratpointbin(3.5,binborder,depoval)
##transform isotope ratio curves
depoval=c(5,4,2,1,0.1)
#create fake ratios and sample locations
sampletime=sort(runif(20,min=min(binborder),max=max(binborder))) #times where the samples were taken
isotoperatio=sin(sampletime)*rnorm(length(sampletime)) #isotope ratios
plot(sampletime,isotoperatio,type='l',xlab='Time',ylab='Isotope Ratio')
#!!transform only (!) sample times, NOT isotope values!!
reslist=timetostratpointbin(sampletime,binborder,depoval)
#this is the resulting isotope ratio curve in stratigraphic height
plot(reslist$height,isotoperatio,type='l',xlab='Stratigraphic Height',ylab='Isotope Ratio')
# }
Run the code above in your browser using DataLab