Re: [R] "reverse" quantile function

2017-06-16 Thread Andras Farkas via R-help
Peter, thanks, very nice, this will work for me... could you also help with setting up the code to run the on liner "approx(sort(x), seq(0,1,,length(x)), q)$y" on the rows of a data frame using my example above? So if I cbind z and res,  df<-cbind(z,res) the "x" in your one liner would be the fi

Re: [R] "reverse" quantile function

2017-06-16 Thread Andras Farkas via R-help
Never mind, I think i figured: z<-df apply(df,1,function(x) approx(sort(x[1:4]), seq(0,1,,length(x[1:4])), x[5])$y) thanks again for the help Andras Farkas, On Friday, June 16, 2017 5:34 AM, Andras Farkas via R-help wrote: Peter, thanks, very nice, this will work for me... could you

Re: [R] "reverse" quantile function

2017-06-16 Thread Andras Farkas via R-help
Peter, thanks, very nice, this will work for me... could you also help with setting up the code to run the on liner "approx(sort(x), seq(0,1,,length(x)), q)$y" on the rows of a data frame using my example above? So if I cbind z and res, df<-cbind(z,res) the "x" in your one liner would be t

Re: [R] "reverse" quantile function

2017-06-16 Thread peter dalgaard
It would depend on which one of the 9 quantile definitions you are using. The discontinuous ones aren't invertible, and the continuous ones won't be either, if there are ties in the data. This said, it should just be a matter of setting up the inverse of a piecewise linear function. To set ide

Re: [R] "reverse" quantile function

2017-06-15 Thread Andras Farkas via R-help
David, thanks for the response. In your response the quantile function (if I see correctly) runs on the columns versus I need to run it on the rows, which is an easy fix, but that is not exactly what I had in mind... essentially we can remove t() from my original code to make "res" look like t

Re: [R] "reverse" quantile function

2017-06-15 Thread David Winsemius
> On Jun 15, 2017, at 12:37 PM, Andras Farkas via R-help > wrote: > > Dear All, > > we have: > > t<-seq(0,24,1) > a<-10*exp(-0.05*t) > b<-10*exp(-0.07*t) > c<-10*exp(-0.1*t) > d<-10*exp(-0.03*t) > z<-data.frame(a,b,c,d) > > res<-t(apply(z, 1, quantile, probs=c(0.3))) > > > > my goa