The problem is that I can't 'insert' the :: operator inside an existing
function. (Well, I could, but that would mean rewriting the function)
I was hoping for a way to call the function, in this case turnpoints()
in some way that told turnpoints itself to look for base::apply
Carl
On 1/3/11 7:28 PM, David Winsemius wrote:
On Jan 3, 2011, at 7:17 PM, Carl Witthoft wrote:
Hi,
Here's the problem I ran into: the gmp package has a method for
apply() so it masks the base::apply function. With gmp installed, I
tried to run the function turnpoints() from the pastecs package. It
fails because it calls apply() internally, like this:
apply(mymatrix,1,max,na.rm=TRUE)
,
but the code in the gmp package which sets up the operator overload
for apply() strictly limits the arguments to the first three (a
matrix, a dimension, and a function). I get, no surprise:
Rgames> xs<-sin(seq(1,100)/10)
Rgames> turnpoints(xs)
Error in apply(ex, 1, max, na.rm = TRUE) :
unused argument(s) (na.rm = TRUE)
I'm assuming this is a bug in gmp code and will ask the owner of that
package about it.
But in the meantime, is there some way to force a function to search
for functions in a different namespace, or at least to search with
packages set in a different order? That is, in this example, to make
turnpoints() look to package base before looking at gmp?
In general the strategy is to use the "::" operator. Try :
base::apply(mymatrix,1,max,na.rm=TRUE)
(Untested in absence of example.)
Thanks for your help and corrections to any of my assumptions and
conclusions here.
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.