R: cannot use functions after install_github - r

I ran install_github('zhangyuqing/sva-devel') (recommended here: https://github.com/jtleek/sva-devel/issues/14) but cannot run the function ComBat() afterwards, getting shows Error in ComBat() : could not find function "ComBat".
More generally put, how do I do in R what import sva-devel does in Python?
I tried
> library('sva')
Error in library("sva") : there is no package called ‘sva’
> library('sva-devel')
Error in library("sva-devel") : there is no package called ‘sva-devel’```

Related

Why does the error "object 'woe.dfrm.final' not found" occure?

I am trying to use an R package woeBinning. When I apply the woe.binning function to my dataset, the following error is displayed:
Error in woe.binning.2(df, target.var, x, min.perc.total, min.perc.class, :
object 'woe.dfrm.final' not found
The woeBinning package provides a test dataset germancredit, the woe.binning function works fine on it, but not on my dataset.
I have looked through the source code of woe.binning.2 (see the link), but could not understand the root of the problem.
https://rdrr.io/cran/woeBinning/src/R/woe.binning.R

PreprocessCore package

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.

undefined function / function not found

I created a package for R to learn how to develop these things and I got a error that I can't resolve. I saw this error was nor uncommon but I could not find a solution.
This is the code of my package (pretty simple):
absconc<-function(x,a,b,...)
{
a<-as.numeric(a)
b<-as.numeric(b)
absconcCalc<- function(x,a,b,...)
{
conc<- (x*a)+b
}
conc<-absconcCalc(x,a,b,...)
print.absconc<- function(x,a,b,...)
{
cat("Slope:")
cat(a,"\n")
cat("Intercept:")
cat(b,"\n")
cat("Concentration:")
cat(conc)
}
print.absconc(x,a,b)
}
I created the package using package.skeleton and it worked like a charm, even the building of the package using R CMD build absconc worked.
The problem was when I trying to use the package it gave me Error: could not find function "absconc".
I though it was a problem coming from NAMESPACE and the export so I tried exporting the functions using export(absconc). When I tried building that I got an error saying:
Error in namespaceExport(ns, exports) :
undefined exports: absconc, absconcCalc, print.absconc
I am now scratching my head to understand why my function are not recognized.
I would appreciate some help on that as this is only my first package.
EDIT: here are my files (A bit messy, sorry)
https://github.com/Frisacher/absconc
You should not edit NAMESPACE by hand. Insert the line #' #export at the top of your R file and run devtools::document() in the console. This will do what is necessary for you.
Now you can execute devtools::load_all() and run your function.
More explicitly:
1) Create a folder named "R" below the root directory and create an R script that contains your function as Martin Morgan suggested in the comments.
2) Add a roxygen comment to your R script to export it:
#' #export
absconc<-function(x,a,b,...)
{
a<-as.numeric(a)
b<-as.numeric(b)
...
}
3) Execute devtools::document() in the console.
> devtools::document()
Updating absconc documentation
Loading absconc
Writing NAMESPACE
4) Load your package with devtools::load_all().
> devtools::load_all()
Loading absconc
5) Run your function.
> absconc(1,2,3)
Slope:2
Intercept:3
Concentration:5

Attempting to use source() in r, but gives grep error

I am attempting to use Muxviz, and I believe that I installed all of the required dependencies (octave, R, g++, gfortan, and GDAL), but I'm getting an error when I try to use "source('muxVizGUI.R')". I says
Error in if (grep("3.2", version$version.string) != 1) { :
argument is of length zero
Any suggestions? I just made sure that R is > 3.2.x.

TCL error with "unfold" function in survival analysis

I am trying to use the unfold function from package RcmdrPlugin.survival.
I used the following command:
long.df <- unfold(testdf,time="deathint", event="death",
cov=list(31:70,71:110), cov.names=c("adopted","age"))
However, R is returning the following error message:
Error in structure(.External(.C_dotTcl, ...), class = "tclObj") :
[tcl] wrong # args: should be "winfo rootx window".
I am using R version 3.2.4. Any suggestions?
I had the same problem in R studio. This is how I solved it:
intall.packages("Rcmdr")
It installed R commander gui for me,then I went to R commander gui, installed and loaded RcdmrPlugin.survival and then I ran unfold from there and it worked.

Resources