#Scanning the data file for seabed and land profile bedland=scan("data-salt-intrusion.txt", skip=2, n=14) bedland=array(bedland,dim=c(2,7)) xbedland=bedland[1,] ybedland=bedland[2,] #Scanning the data file for freshwater profile freshw=scan("data-salt-intrusion.txt", skip=12) freshw=array(freshw,dim=c(2,5)) xfreshw=freshw[1,] yfreshw=freshw[2,] #Removing temporary files rm(freshw,bedland) #Drawing the plot plot(xbedland,ybedland,type="l") lines(xfreshw,yfreshw,col="blue") lines(c(0,80),c(5.5,5.5),lwd=2,col="red") lines(c(80,140),c(5.5,5.5),lwd=1,col="red",lty=2) #Smoothing the freshwater surface pr1=approx(xfreshw,yfreshw,xout=seq(80,140,1)) pr1=smooth.spline(pr1$x,pr1$y,spar=0.8) #Computing h h=pr1$y-5.5 # Computing H H=-40*h+5.5 #Plotting saltwater wedge lines(pr1$x,H,col="orange",lwd=2)