Displaying 11 results from an estimated 11 matches for "newfun".
Did you mean:
newfunc
2013 Mar 26
2
when to use which apply function?
Dear list,
I am a little confused as to when to use apply, sapply, tapply, vapply,
replicate. I've encountered this several times,
This is time, this is what I am working on,
mat <- matrix(c(seq(from=1, to=10), rnorm(10)), ncol=2)
a=1; b=5
newfun <- function(x, y, a, b)
{
x*y+a+b
}
sapply(i=1:10, newfun(x=mat[i, 1], y=mat[i, 2], a=a, b=b))
Error in match.fun(FUN) : argument "FUN" is missing, with no default
I want to use ith row of mat, evaluate newfun(). Am I making a parameter
mistake, or should I use a different app...
2015 Jan 21
2
reducing redundant work in methods package
...[fname]] = list() # Actually probably not necessary, will
just be c(NULL, list(first result)) the first time
# Construct test version of function
unlockBinding(fname, ns)
fun = get(fname, envir=ns, mode="function")
funbody = deparse(body(fun))
newfun <- fun
newfun.body = c(
sprintf("fname = '%s'", fname),
"TEST_INFO = list()",
"TEST_INFO$input = mget(names(formals(fname)))",
c("realfun <- function()", funbody),
"T...
2015 Jan 21
2
reducing redundant work in methods package
...result)) the first time
>>
>> # Construct test version of function
>>
>> unlockBinding(fname, ns)
>>
>> fun = get(fname, envir=ns, mode="function")
>>
>> funbody = deparse(body(fun))
>>
>> newfun <- fun
>>
>> newfun.body = c(
>>
>> sprintf("fname = '%s'", fname),
>>
>> "TEST_INFO = list()",
>>
>> "TEST_INFO$input = mget(names(formals(fname)))",
>>
>&g...
2011 Aug 08
1
Overwriting imported function in another package
...for lattice, because it imports
grid. Is there any way to overwrite grid.newpage for all
instantiations of it?
#packages
library(grid);
library(lattice);
library(ggplot2);
#create the modified function.
hookfun <- deparse(body(plot.new))[1:6]
oldfun <- deparse(body(grid::grid.newpage))[-1];
newfun <- grid::grid.newpage;
body(newfun) <- parse(text=c(hookfun, oldfun));
#overwrite it in the package
unlockBinding("grid.newpage", as.environment("package:grid"))
assign("grid.newpage", newfun, pos="package:grid")
#this seems ok:
get('grid.newpage&...
2015 Aug 13
2
[lld] Alias in COFF short import library.
...e
> defines bunch of aliases, and you can do the same thing.
>
Thanks for pointing me in the right direction :)
After looking at oldnames.lib I done a little more reading and I assume I
do it like this then for the alias.
The import table points to the functions like this.
__imp_oldfu -> newfun.obi
oldfu -> newfun.obj
I have attached the 2 files named here.
I assume this is what you meant by Weak Externals ?
On Thu, Aug 13, 2015 at 6:36 AM, Rui Ueyama <ruiu at google.com> wrote:
> Hmm, that's not correct too. All symbols listed in the archive header must
> be defin...
2015 Jan 21
0
reducing redundant work in methods package
...ry, will
> just be c(NULL, list(first result)) the first time
>
> # Construct test version of function
>
> unlockBinding(fname, ns)
>
> fun = get(fname, envir=ns, mode="function")
>
> funbody = deparse(body(fun))
>
> newfun <- fun
>
> newfun.body = c(
>
> sprintf("fname = '%s'", fname),
>
> "TEST_INFO = list()",
>
> "TEST_INFO$input = mget(names(formals(fname)))",
>
> c("realfun <- fun...
2015 Jan 22
0
reducing redundant work in methods package
...t;>> # Construct test version of function
>>>
>>> unlockBinding(fname, ns)
>>>
>>> fun = get(fname, envir=ns, mode="function")
>>>
>>> funbody = deparse(body(fun))
>>>
>>> newfun <- fun
>>>
>>> newfun.body = c(
>>>
>>> sprintf("fname = '%s'", fname),
>>>
>>> "TEST_INFO = list()",
>>>
>>> "TEST_INFO$input = mget(names(formals...
2001 Mar 20
3
Newbie question about by() -- update
Sorry about the lack of detail. I am running R v.1.2.2. I can recast my
question
(which I think I have partially answered) more succinctly as follows:
1. This seems to work (note that group takes values 1,2,3,4, or 5):
my.newfun <- function(x) myfile <- lm(award ~ ilogemp + ilogage, x)
test.by <- by(wintemp, as.factor(wintemp$group), my.newfun)
2. This does not work (leaving aside whether I am using ppr correctly or not!):
> my.pprfun <- function(x) mypprfile <- ppr(award ~ ilogemp + ilogage, data = x,...
2015 Aug 13
2
[lld] Alias in COFF short import library.
>
> The header of libuser32b.a says that it defines MessageBoxB and
> __imp_MessageBoxB, but the import library file in the archive actually
> defines MessageBoxA (not B). So the archive file is broken. You may want to
> fix the header and try again.
Yes this is how I done the alias.
If you consider this invalid then look at libuser32.a
The header defines MessageBoxA and
2004 Jul 14
2
tracing something in a namespace (PR#7091)
...###
> x <- rnorm(10)
> y <- 1:10
> xyplot(y ~ x)
> trace(lattice:::print.trellis, exit=recover)
[1] "print.trellis"
Warning message:
Assigning over the binding of symbol "print.trellis" in environment/package "lattice"
in: .assignOverBinding(what, newFun, whereF)
> xyplot(y ~ x)
> untrace(lattice:::print.trellis)
Error in untrace(lattice:::print.trellis) :
Argument what should be the name of a function
>
Something isn't right. I see three possibilities.
a. tracing something in a namespace is prohibited and I didn't get an e...
2018 Aug 13
1
trace in uniroot() ?
Despite my years with R, I didn't know about trace(). Thanks.
However, my decades in the minimization and root finding game make me like having
a trace that gives some info on the operation, the argument and the current function value.
I've usually found glitches are a result of things like >= rather than > in tests etc., and
knowing what was done is the quickest way to get there.