data_polate | R Documentation |
Linearly extrapolate/interpolate variables in a numeric matrix data
. This function uses Hmisc::approxExtrap()
and base::apply()
to extrapolate variables y_i to y_n in a data frame based on univariate relationships with a variable x (x
; which is another variables in data
) to a new variable xout
.
data_polate(data, xname = NULL, ynames = NULL, xout = NULL)
data |
a numeric matrix or data frame that can be coerced to a numeric matrix with column names containing the x variable and y_i variables to extrapolate |
xname |
the name of the column containing the x variable. If |
ynames |
the names of the columns containing the y variables. If |
xout |
a numeric vector of values to x values to extrapolate y_i to. If |
Users should be cautious about conducting linear extrapolation for relationships that are known to be non-linear over a large range, because they will undoubtedly deviate from the true non-linear relationships. Linear interpolation will also deviate, though the risks will tend to be less severe especially if the resolution of the original data is relatively fine.
Nikolai Klibansky
## Not run:
mydata <- rdat_RedGrouper$a.series
out <- data_polate(mydata,xout=seq(min(mydata$age),max(mydata$age),by=0.5))
par(mfrow=c(1,1))
for(i in colnames(out[,-1])){
x <- mydata[,1]
xout <- out[,1]
yout_i <- out[,i]
plot(xout,yout_i,ylab=i)
points(x,mydata[,i],col="red",pch=16)
readline(prompt="Press [enter] to continue")
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.