Displaying 20 results from an estimated 160 matches for "approxfun".
2007 Mar 15
1
How to use result of approxfun in a package?
I am working on a project where we start with start with 2 long,
equal-length vectors, massage them in various ways, and end up with a
function mapping one interval to another. I'll call that function
"f1." The last step in R is to generate f1 as the value of the
approxfun function. I would like to put f1 into a package, but
without having the package redo the creation of function f1. The
value of approxfun is a function; for example, I have
> f1
function (v)
.C("R_approx", as.double(x), as.double(y), as.integer(n), xout =
as.double(v),
as.i...
2013 Feb 14
1
approxfun values
Readers,
According to the help '?approxfun', the function can be used to obtain
the interpolated values. The following test was tried:
> testinterpolation<-read.csv('test.csv',header=FALSE)
> testinterpolation
V1 V2
1 10 2
2 20 NA
3 30 5
4 40 7
5 50 NA
6 60 NA
7 70 2
8 80 6
9 90 9
10 100 NA...
2008 Sep 01
2
Interpolation Problems
...gree to 0.5 degrees) to match that of a corresponding dataset.
I have the data in both a data frame format (longitude column header values along the top with latitude row header values down the side) or column format (in the format latitude, longitude, value).
I have used Google to determine 'approxfun' the most appropriate command to use for this purpose - I may well be wrong here though! Nevertheless, I've tried using it with the default arguments for the data frame (i.e. interp <- approxfun(dataset) ) but encounter the following errors:
> interp <- approxfun(JanAv)
Error in a...
2010 Aug 25
3
approxfun-problems (yleft and yright ignored)
Dear all,
I have run into a problem when running some code implemented in the
Bioconductor panp-package (applied to my own expression data), whereby gene
expression values of known true negative probesets (x) are interpolated onto
present/absent p-values (y) between 0 and 1 using the *approxfun -
function*{stats}; when I have used R version 2.8, everything had
worked fine,
however, after updating to R 2.11.1., I got unexpected output (explained
below).
Please correct me here, but as far as I understand, the yleft and yright
arguments set the extreme values of the interpolated y-values in...
2010 Sep 15
1
approxfun returning value higher than I would expect
Below is the code that I am using in a much larger function. I would
expect a bankfull measure at zero to be between 0.6 and 0.8 approxfun
is returning 0.8136986. I am sure that I am missing something.
measure_bkf <- (structure(list(measurment_num = c(0, 0.2, 0.4, 0.6,
0.8, 1, 1.2,
1.4, 1.6, 1.8, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.2, 3.4), bankfull_depths_m
= c(-0.48,
-0.48, -0.42, -0.26, 0.58, 0.48, 0.47, 0.54, 0.5, 0.52, 0.52,
0.56, 0...
2016 May 01
2
Storage of byte code-compiled functions in sysdata.rda
...ly treat/store byte-code compiled
functions, as we have no problems with R-3.1.3, but do see an "Error in fct(x) : byte code
version mismatch" with R-devel SVNrev r70532.
Background:
Starting from several x-y grids, in the sysdata.rda file of RobAStRDA, we store the results
of calls to approxfun/splinefun to these grids from within a session with pkg RobAStRDA
require()d. From pkg RobExtremes we then call these interpolating functions by means of
a call (essentially) as:
getFromNamespace(".RMXE", ns = "RobAStRDA")[["GEVFamily"]][["fun.N"]][[1]](1...
2008 Jun 19
1
error related to approxfun in R 2.7.0
I'm testing R version 2.7.0 on windows and there seems to be a
compatibility issue with objects that were created by "approxfun" in
older versions. As long as the objects were created in version 2.7.0
things work ok, but calling the interpolated functions from R version
2.0.1 causes this error:
Error in .C("R_approx", as.double(x), as.double(y), as.integer(n),
xout = as.double(v), :
C symbol name "R_...
2001 Jun 18
1
approxfun(*, ties=) returning "random" result (PR#986)
Platforms : SunOS and Linux, both using gcc 2.95.[23]
R versions : 1.2.3 and "R-devel"
I came accross this when trying to debug a somewhat sub-optimal behavior of
ecdf() from package stepfun.
What happens is that approxfun(*, ties = <function>)
does not always return the same result for identical arguments.
I tried "min", "max", and "mean" all of which are mentioned on the help page.
>From looking at both R and C code, I wonder if the bug is not even deep
inside where .C(......)...
2008 Mar 26
0
approxfun + save: problem as R_approx changed package
Hi all,
I recently switched to R version 2.6.2 (from 2.5.0 I was using) on Windows XP.
I have a fair amount of previous data saved in the form of "approxfun" objects created by version 2.5.0, with code basically like this:
> x <- rlnorm(100,10,2)
> f <- approxfun(1:100,x)
> f(5)
[1] 313811.3
> save(f, file="mytest_approx.Rdata")
Now on 2.6.2, when I try to reuse the saved object I get an error:
> attach("myte...
2016 May 01
2
Storage of byte code-compiled functions in sysdata.rda
...version;
so please follow steps (1)--(6) below; I am not 100% sure whether this already gives
you all information needed for this, but if not so please let me know.
(1) create a minimal R-package "InterpolTry"
with byte-compilation on in the DESCRIPTION file
and with stats::approxfun imported in the NAMESPACE file
(2) in an R session on R-devel do
require(InterpolTry)
x <- 1:100
y <- 1:100
fun <- approxfun(x,y)
## revise the next line accordingly to your local settings
SrcRPathInterpolTry <- <path_to_(source-)R-folder_of_InterpolTry>
RdaFile <- file....
2009 Jan 07
1
proto question
...={
start.year <- 2008
end.year <- 2050
})
star.rating <- wedge$proto(
star = c(4, 5, 8, 10),
gain = c(0, .3, .5, .7),
cost = c(0, 2100, 4000, 7500),
star.rating <- function(., year) 6.0,
setup = function(.){
.$cost.for.star <- approxfun(.$star, .$cost)
.$gain.for.star <- approxfun(.$star, .$gain)
},
test = function(., year) {
gs <- .$with(gain.for.star)(.$star.rating(year))
}
)
And a function to create and modify 'instances':
create.star.rating <- function(switch....
2003 Sep 23
1
AW: Rank and extract data from a series
...;t work so well for distributions that have the great majority of
> > the probability mass concentrated in a small fraction of the sample
> > space. I was hoping for something that would retain the
> > adaptability of integrate().
>
> Yesterday, I've suggested to use approxfun(). Did you consider my
> suggestion? Below is an example.
>
> N <- 500
> x <- rexp(N)
> y <- rank(x)/(N+1)
> empCDF <- approxfun(x,y)
> xvals <- seq(0,4,.01)
> plot(xvals,empCDF(xvals),type="l",
> xlab="Quantile",ylab="Cumulative D...
2016 May 05
0
Storage of byte code-compiled functions in sysdata.rda
...ollow steps (1)--(6) below; I am not 100% sure whether this already gives
> you all information needed for this, but if not so please let me know.
>
> (1) create a minimal R-package "InterpolTry"
> with byte-compilation on in the DESCRIPTION file
> and with stats::approxfun imported in the NAMESPACE file
>
> (2) in an R session on R-devel do
>
> require(InterpolTry)
> x <- 1:100
> y <- 1:100
> fun <- approxfun(x,y)
> ## revise the next line accordingly to your local settings
> SrcRPathInterpolTry <- <path_to_(source-)R-folder_...
2006 Oct 27
1
(no subject)
...e generated a profile likelihood for a parameter (x) and am
trying to get 95% confidence limits by calculating the two points
where the log likelihood (LogL) is 2 units less than the maximum
LogL. I would like to do this by linear interpolation and so I have
been trying to use the function approxfun which allows me to get a
function to calculate LogL for any value of x within the range of x
values.
My data frame can be entered as follows:
dat = data.frame(x = c(0.00000, 0.00010, 0.00100, 0.01000, 0.02404,
0.02404, 0.07603, 0.07603, 0.10000, 0.12021, 0.12021, 0.15146,
0.15146, 0.19083,...
2016 May 01
0
Storage of byte code-compiled functions in sysdata.rda
...led
> functions, as we have no problems with R-3.1.3, but do see an "Error in fct(x) : byte code
> version mismatch" with R-devel SVNrev r70532.
>
> Background:
> Starting from several x-y grids, in the sysdata.rda file of RobAStRDA, we store the results
> of calls to approxfun/splinefun to these grids from within a session with pkg RobAStRDA
> require()d. From pkg RobExtremes we then call these interpolating functions by means of
> a call (essentially) as:
>
> getFromNamespace(".RMXE", ns = "RobAStRDA")[["GEVFamily"]][["...
2009 Aug 07
0
Problem with area()
I'm using area() to evaluate the area under
2 functions (defined using approxfun()) and the result is in contradiction
with visual inspection (please see:
http://sites.google.com/site/eospansite/dummy/problem_area.jpg
)
The area under the red curve should be larger
than the one under the black curve, but I'm
geting the opposite result using area().
This is what I'm do...
2010 Feb 03
1
Additional field data collection
This is a subset of a much larger dataframe. I would like to be able
to automate finding the pair of x, y coordinates where the line
crosses zero agian
x <- (structure(list(bankfull_depths_m = c(0, 0.17, 0.38, 0.37, 0.36,
0.39, 0.47, 0.48, 0.19, 0.05, -0.05, -0.09), measurment_num_m = c(0.2,
0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4)), .Names =
c("bankfull_depths_m",
2013 Oct 31
1
Extracting values from a ecdf (empirical cumulative distribution function) curve
Hi R users,
I am a new user, still learning basics of R. Is there anyway to extract y
(or x) value for a known x (or y) value from ecdf (empirical cumulative
distribution function) curve?
Thanks in advance.
Mano.
[[alternative HTML version deleted]]
2003 Sep 23
0
Rank and extract data from a series
...t have the great
> majority of
> > > the probability mass concentrated in a small fraction of
> the sample
> > > space. I was hoping for something that would retain the
> > > adaptability of integrate().
> >
> > Yesterday, I've suggested to use approxfun(). Did you consider my
> > suggestion? Below is an example.
> >
> > N <- 500
> > x <- rexp(N)
> > y <- rank(x)/(N+1)
> > empCDF <- approxfun(x,y)
> > xvals <- seq(0,4,.01)
> > plot(xvals,empCDF(xvals),type="l",
> > xlab...
2018 Mar 07
0
ggplot2: plot gruped/nested split violins
...le_grob))
}
else {
ggplot2:::ggname("geom_split_violin",
GeomPolygon$draw_panel(newdata, ...))
}
})
create_quantile_segment_frame <- function (data, draw_quantiles, split
= FALSE, grp = NULL) {
dens <- cumsum(data$density)/sum(data$density)
ecdf <- stats::approxfun(dens, data$y)
ys <- ecdf(draw_quantiles)
violin.xminvs <- (stats::approxfun(data$y, data$xminv))(ys)
violin.xmaxvs <- (stats::approxfun(data$y, data$xmaxv))(ys)
violin.xs <- (stats::approxfun(data$y, data$x))(ys)
if (grp %% 2 == 0) {
data.frame(x = ggplot2:::interleave(vio...