[R] Linear Interpolation help please

Andras Farkas motyocska at yahoo.com
Wed May 23 04:03:23 CEST 2012


Dear experts
 
I have gotten this far with the question I have posted the other day, but wonder if someone could help me refine it. The following command will do the interpolationand plot it for the file attached:
 
data <- read.csv("C:\\Users\\andras\\Documents\\Subject1.csv")
x <-data$x
y <-data$y
Interpolated <- approx(x, y,xout=0:144,method="linear")
plot(Interpolated)
 
This command will tell me the fraction of the time spent between the values of 2 and 3(x axis is time in hours):
 
TITR.1 <- 1- ((length(which(Interpolated$"y"<2))+length(which(Interpolated$"y">3)))/length(Interpolated$"y"))
 
This command will tell me the total hours to get to the value of 2:
 
timetorange <- with(Interpolated, approx(x, y, xout=c(0:144))) 
TTR.1 <- length(timetorange$"y")-length(which(timetorange$"y">=2))
 
This set up allows me to examine 1 profile at once only. Would someone have any ideas on how I could include more then 1 profile in the same csv file and then analyze each profile separately?
 
thanks,
 
Andras


More information about the R-help mailing list