similar to: R object as a function

Displaying 20 results from an estimated 600 matches similar to: "R object as a function"

2005 Jun 07
9
how to define functions in such a situation
hi R folks, I need read a file from hardisk or www web. Then I need to define some new functions according to the contents of the read file. For example, i need write a package name "mypackage" like this: >library(mypackage) >read(some_file_on_web) #to see its content, suppose it contains: eat.drink.sleep then 3 new functions need to be created and usable. the problem is, how
2009 Dec 06
2
Error in eval(expr, envir, enclos) : object 'N' not found
I'm running an LSODA to generate some graphs, but I need to stop at a certain point and use those values to generate another LSODA output. This is working fine, but when I try to run the second LSODA, I get the "Error in eval(expr, envir, enclos) : object 'N' not found". Any ideas what can be causing this? I have no object 'N' anywhere in the script. I made an
2002 Dec 12
0
if problem in function
Dear all, I have written a function for calculating the volume of a tree (=trad) or snag (=h?gst). The included volume regreesion model includes ten parameter values, which are tree species specific. bj?rk.formh?jd.pars is an object which includes the parameter values (parameter set) for birch (=bj?rk). There is one row per tree in the data object. > relev.kols[1:5,
2010 Oct 21
1
gam plots and seWithMean
hello I'm learning mgcv and would like to obtain numerical output corresponding to plot.gam. I can do so when seWithMean=FALSE (the default) but only approximately when seWithMean=TRUE. Can anyone show how to obtain the exact values? Alternatively, can you clarify the explanation in the manual "Note that, if seWithMean=TRUE, the confidence bands include the uncertainty about the
2017 Jun 18
2
R_using non linear regression with constraints
I am using nlsLM {minpack.lm} to find the values of parameters a and b of function myfun which give the best fit for the data set, mydata. mydata=data.frame(x=c(0,5,9,13,17,20),y = c(0,11,20,29,38,45)) myfun=function(a,b,r,t){ prd=a*b*(1-exp(-b*r*t)) return(prd)} and using nlsLM myfit=nlsLM(y~myfun(a,b,r=2,t=x),data=mydata,start=list(a=2000,b=0.05), lower = c(1000,0),
2011 Jul 23
1
call a function with explicitly not setting an argument
Is there a way to call a function, and explicitly set an argument to 'not specified'? My situation is the following. I have a function which passes on most of its arguments to another function. The second function, myfun2, serializes all arguments and is out of my control. myfun <- function(...){ return(myfun2(...)); } now, the value for arguments of myfun are stored in variables.
2017 Jun 18
3
R_using non linear regression with constraints
I am not as expert as John, but I thought it worth pointing out that the variable substitution technique gives up one set of constraints for another (b=0 in this case). I also find that plots help me see what is going on, so here is my reproducible example (note inclusion of library calls for completeness). Note that NONE of the optimizers mentioned so far appear to be finding the true best
2017 Jun 18
3
R_using non linear regression with constraints
https://cran.r-project.org/web/views/Optimization.html (Cran's optimization task view -- as always, you should search before posting) In general, nonlinear optimization with nonlinear constraints is hard, and the strategy used here (multiplying by a*b < 1000) may not work -- it introduces a discontinuity into the objective function, so gradient based methods may in particular be
2017 Jun 18
0
R_using non linear regression with constraints
I ran the following script. I satisfied the constraint by making a*b a single parameter, which isn't always possible. I also ran nlxb() from nlsr package, and this gives singular values of the Jacobian. In the unconstrained case, the svs are pretty awful, and I wouldn't trust the results as a model, though the minimum is probably OK. The constrained result has a much larger sum of squares.
2017 Jun 18
0
R_using non linear regression with constraints
> On Jun 18, 2017, at 6:24 AM, Manoranjan Muthusamy <ranjanmano167 at gmail.com> wrote: > > I am using nlsLM {minpack.lm} to find the values of parameters a and b of > function myfun which give the best fit for the data set, mydata. > > mydata=data.frame(x=c(0,5,9,13,17,20),y = c(0,11,20,29,38,45)) > > myfun=function(a,b,r,t){ > prd=a*b*(1-exp(-b*r*t)) >
2006 Jul 06
2
use of apply in a data frame on a row by row basis
Hello all, I'm trying to use the apply function on a data frame, by applying a function that takes a one row data.frame as argument . Here's the example : myfun = function(x) paste(x$f1 , x$f2) df = data.frame(f1 = c(1,4,10),f2 = "hello") apply(df,1,myfun) ==> Does not work (I get "character(0)" ) Though : myfun(df[1,]) works, and myfun(df) works as well. So if
2012 Jul 02
2
Constructing a list using a function...
Hi All I have a dataframe: myframe<-data.frame(ID=c("first","second"),x=c(1,2),y=c(3,4)) And I have a function myfun: myfun<-function(x,y) x+y I would like to write a function myfun2 that takes myframe and myfun as parameters and returns a list as below: mylist $first [1] 4 $second [2] 6 Could you please help me with this? Doesn't seem like the
2017 Jun 18
0
R_using non linear regression with constraints
I've seen a number of problems like this over the years. The fact that the singular values of the Jacobian have a ration larger than the usual convergence tolerances can mean the codes stop well before the best fit. That is the "numerical analyst" view. David and Jeff have given geometric and statistical arguments. All views are useful, but it takes some time to sort them all out and
2011 Sep 03
2
problem in applying function in data subset (with a level) - using plyr or other alternative are also welcome
Dear R experts. I might be missing something obvious. I have been trying to fix this problem for some weeks. Please help. #data ped <- c(rep(1, 4), rep(2, 3), rep(3, 3)) y <- rnorm(10, 8, 2) # variable set 1 M1a <- sample (c(1, 2,3), 10, replace= T) M1b <- sample (c(1, 2,3), 10, replace= T) M1aP1 <- sample (c(1, 2,3), 10, replace= T) M1bP2 <- sample (c(1, 2,3), 10, replace= T)
2004 Mar 11
1
how to pass extra parameters using call() or similar mechanism ?
I am trying to write a function, which would allow to call various methods and would pass to them extra arbitrary parameters. My first attempt was to use call() as illustrated below, but apparently '...' cannot be used in such context. How can this be achieved ? Best regards, Ryszard > myfun <- function(method, x, ...) { + v <- eval(call(method, x, ...)) + } > method =
2011 Jul 25
1
do.call in "with" construction
Dear all, I'd appreciate any help to rectify what must be a misconception of mine how environments work: ########################## myEnv <- new.env() myEnv$a.env <- 1 myEnv$symbols.env <- "a.env" a.global <- 2 symbols.global <- "a.global" myFun <- function(symbols){do.call("print", lapply(symbols, FUN=as.name))} do.call("myFun",
2009 May 26
1
stricter use of xlim in plot.stepfun
Dear R developer, I am not quite sure, if I should post my concern as a wish to r-bugs at r-project.org. Thus, as recommended, I first send an email to you. My request is the following: I would appreciate, if it was possible to obtain a plot of a 'stepfun' with a strict interpretation of xlim. What I mean: sf <- stepfun(1:4, 1:5) plot(sf, xlim=c(0,10)) does not bound the function to
2003 Nov 17
4
cumulative distribution functions
hi y'all, I am wondering if there is any special command, function, package, etc to help me doing a cumulative distribution function, with y-scale - probability scale. I tried the help in R and i got the following answers: cumsum(base) Cumulative Sums, Products, and Extremes ecdf(stepfun) Empirical Cumulative Distribution Function cpgram(ts) Plot
2002 Jul 25
1
Calling the correct one of 2 conflicting functions
Hello, My specific system is > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 5.1 year 2002 month 06 day 17 language R Each of the hmisc and stepfun packages has a function
2011 Feb 08
1
help on stepfunction
Dear members, I would like a help for extracting the values from a step function (stepfun). >From help(stepfun) we have the following example: Y0<-c(1.,2.,4.,3.) y0<-c(1.,2.,3.,4.) sfun<-stepfun(1:3,y0,f=0) plot(sfun) Now, suppose instead I was given the object (*sfun*, say) from which I wanted to extract the values generated by the function *stepfun*. More precisely, I want to