I'm pulling my hair out over this seemingly simple problem. I am trying to change a function in the hglm package; specifically the private hglm.default function.
Here is what I've done:
library(hglm)
e<-loadNamespace("hglm")
unlockBinding("hglm.default",e)
assignInNamespace("hglm.default",...my edits...,ns="hglm",envir=e)
lockBinding("hglm.default",e)
However, when I do
environment(hglm:::hglm.default)
I get
<environment: R_GlobalEnv>
which is problematic; it needs to be in the namespace environment for hglm (<environment: namespace:hglm>) or else it doesn't work. If I try to set the environment with
environment(hglm:::hglm.default)<-e
I get the error
Error in loadNamespace(name) : there is no package called ‘*tmp*’
I've tried all sorts of permutations of this and can't seem strike the right one. I am a total novice on namespaces, etc, so hopefully someone knowledgable can help out!
Thanks in advance.
Related
can someone please help me understand this:
I encountered an error when calling a function from a library, specifically "steinertree" from the "SteinerNet" package. When stepping into the function with debug(steinertree), I see that the error occurs, when the function in turn calls "steinertree3". When I try debug(steinertree3), I get "object 'steinertree3' not found". Similarly, I can get the code for 'steinertree' by typing it in the terminal, but not for 'steinertree3'.
So it seems to me that there are some "higher-level" functions and "hidden" functions in packages. I did eventually find the error by finding a file "steinertree.R" in the package at CRAN, which contains both 'steinertree' and 'steinertree3', but I`m wondering how to properly go about debugging such "hidden" functions.
Here is a simple example:
library(igraph)
library(SteinerNet)
set.seed(1)
g= erdos.renyi.game(n=10,p.or.m=0.2)
plot(g)
steinertree(type= 'KB', terminals= c(1,3), graph= g)
Thank you!
Use triple colon ::: to execute a function that is not exported by the package/namespace:
package:::hidden_function()
I'm quite new to R and I got an assignment that includes a sourcecode.
Part of the source code includes the following line:
library(preprocessCore)
Then I have in my source code a definition of the following function:
quantile.normalize.raw.gtex <- function(edata.mat)
{
norm_edata = normalize.quantiles(as.matrix(edata.mat))
rownames(norm_edata) = rownames(edata.mat)
colnames(norm_edata) = colnames(edata.mat)
return(norm_edata)
}
Finally, I have an object being initialized to the output of this function, after sending a predefined parameter:
tissue.edata.qn = quantile.normalize.raw.gtex(tissue.edata)
From what I understand, the library function is supposed to include the function normalize.quantiles, which is called in the function that is defined in my source code.
However, when I run the line library(preprocessCore) I get the following error:
Error in library(preprocessCore) :
there is no package called ‘preprocessCore’
I also tried to run the rest of the code and got the error:
Error in normalize.quantiles(as.matrix(edata.mat)) :
could not find function "normalize.quantiles"
I looked for the preprocessCore online and eventually I tried to write install.packages("preprocessCore"), but I got a warning message that this package is only available in version 3.6.0 of R, even though I checked and this is the version that I have.
If somebody has any idea what the problem is, I will appreciate your help.
Thanks in advance
The preprocessCore package is available in Bioconductor. So, to install it, you need the following lines:
source("http://bioconductor.org/biocLite.R")
biocLite("preprocessCore")
After that, you can load the package using library(preprocessCore)
Hope it helps.
I have the package mi installed.
But when I try to run mp.plot (as Thomas Leeper does in this tutorial:) I get the following error message:
mp.plot(mydf)
Error in mp.plot(mydf) : could not find function "mp.plot"
On one website this is called missing.pattern.plot, but that also does not work:
missing.pattern.plot(mydf)
Error in missing.pattern.plot(mydf) :
could not find function "missing.pattern.plot"
Any idea what the issue might be?
I do not really care much if I cannot use this function, but I'm curious as to what is going on in case I later need to use a graph that I really need.
Hope you can give me a quick help:
I have a function that works perfect as run in the global envir. When I eval the function from my own package it gives me an error. I can't figure out what the problem is. Seem so random to me.
catTableFun(aaa,grouped_by = "varNameAsString",preview=T) #from global envir works as expected
elricoFuns::catTableFun(aaa,grouped_by = "varNameAsString",preview=T) # identical function run from package gives the following error
Error:
#Error in get(grouped_by) : object 'varNameAsString' not found
Its such a construct causing the error. But why?
setDT(x)
gnLevels <- x[,get(grouped_by),drop=F]
I'm sorry I cant give you some rep example and this is a broad question, but I hope someone has encountered a similar phenomenon or has an educated guess about it.
I'm new to R/web services.
I'm trying to use R's SSOAP package to get/post soap messages.
I want to generate functions definitions using the genSOAPCLientInterface by way of the processWSDL function.
when i run the processWSDL function, i get the following error message, which i dont know how to interpret:
Error in SOAPType(el, namespaceDefs=namespaceDefinitions):could not find function "SOAPType"
any help/pointers would be very helpful.
wsdl_doc<-xmlParse(paste0(wsdl_url, '?wsdl')
definitions<-processWSDL(wsdl_doc, verbose=T, useInternalNodes=T)
Error in SOAPType(el, namespaceDefs = namespaceDefinitions) :
could not find function "SOAPType"
SOAPType is a class used in SSOAP package, but it is declared in package XMLSchema. And for some reason it is not an exported class.
This workaround helped me to make the function processWSDL() working for me:
SOAPType = XMLSchema:::SOAPType
def <- processWSDL(doc)