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

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.

Related

Trouble with working directory and {reticulate}

I'm trying to use {reticulate} to load in a .pkl file. So far I've just loaded the package and tried to import pandas, i.e.:
library(reticulate)
pd<-import("pandas")
For some reason I'm getting this error, but can't make any sense of it:
Error: invalid version specification ''/home'', '..EXE was started with the above path as the current directory.', '. paths are not supported. Defaulting to Windows directory.'
In addition: Warning message:
In if (grepl("\\.$", v)) v <- paste0(v, "9000") :
the condition has length > 1 and only the first element will be used
Any tips?

slackr_setup() regression: Error in if (nrow(chan) == 0) { : argument is of length zero

When I am trying to setup my slack environment variables with slackr_setup, I receive the following error:
Error in if (nrow(chan) == 0) { : argument is of length zero
I read that updating the slackr package with devtools::install_github("mrkaye97/slackr")
"would do the trick" but i still receive the same error and I am pretty confused. If anyone has a workaround that would be incredible!
do you mind posting a reprex if possible that shows the issue? My guess is that this is fixed in the newest version of slackr (2.2.0), which you can install via CRAN or Github now, but if you try updating and keep getting this issue, I'd like to fix it!

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.

MonetDB embedded R code debugging

In my efforts to work around the issue mentioned here:
MonetDB connect to GO.db within R code that is run in-database
I went ahead and copied the code from WGCNA that I needed to my own package and installed it. Obviously, I now can load the package without any issues (since I didn't need the GO.db part).
However, I seem to run into another issue:
Server says '!Error running R expression. Error message: Error in
.C("corFast", x = as.double(x), nrow = as.integer(nrow(x)), ncolx =
as.integer(ncol(x)), : '.
I indeed wanted to use the faster cor function from WGCNA, but apparently the C call now creates another issue.
Unfortunately, the message is not informative. I already tried to run the query interactively and adding debug to the statement. This did not provide me with more information.
Is there anything that I can do to increase the verbosity, so that I can debug the proces?
I also tried:
options(monetdb.debug.query=F)
This resulted in a bit of extra output prior to the query, but no extra output on the error that occurred.
Using the suggestion of Hannes Muehleisen I added:
options(monetdb.debug.mapi=T)
It does add a little more information, which allowed me to proceed a bit further. I am now stuck with the following error, which seems again truncated.
QQ: 'SELECT * FROM cor_test();' TX: 'sSELECT * FROM cor_test(); ; RX:
'!Error running R expression. Error message: Error in .C("corFast", x
= as.double(x), nrow = as.integer(nrow(x)), ncolx = as.integer(ncol(x)), : ! "corFast" not available for .C() for
package "MRMRF Error in .local(conn, statement, ...) : Unable to
execute statement 'SELECT * FROM cor_test();'. Server says '!Error
running R expression. Error message: Error in .C("corFast", x =
as.double(x), nrow = as.integer(nrow(x)), ncolx = as.integer(ncol(x)),
: '.
Yes this is a known issue where only the first line of the error message is returned. We should fix this. I always use stop(whatever) to return some info from within the UDF.

Problems building an R package (NAs introduced by coercion)

I have written the Boggler package which includes a Play.Boggle() function that calls, on line 87, a progress bar script using shell:
shell(cmd = sprintf('Rscript.exe R/progress_bar.R "%i"', time.limit + 1), wait=FALSE)
Everything works fine when sourcing the files individually and then calling the main Play.Boggle() function, but when I try to check/build the package (under Win7-64 using RStudio), I get a failure message -- here's what the 00install.out reports:
** preparing package for lazy loading
Warning in eval(expr, envir, enclos) : NAs introduced by coercion
Error in time.limit:0 : NA/NaN argument
To make sure the argument "%i" (time.limit + 1) was correctly passed to the progress_bar.R, I added a cat(time.limit) to the script (commenting the rest out to make sure the package would build without any errors) and directed its output to a log file like this:
'Rscript.exe R/progress_bar.R "%i" > out.log'
Conclusion: the time limit is indeed passed along as expected. So I can't figure out why I get this "NA/NaN argument" error message. It must have something to do with lazy loading, concept that I haven't fully got my head around yet.
So my question is: what can I do to successfully check/build this package with full functionality (including progress_bar.R)?
Note: On github, the progress_bar.R script is there but all its content is commented out so that the package can successfully be installed. The shell(...) function call is still active, doing nothing but executing an empty script.
So the problem arises when trying to build or check, in which case all R scripts are executed, as pointed out by Roland. A simple workaround allows the package to check/build without any problems. The fix is just to add to the progress_bar.R the following lines after it tries to recuperate the commandargs (lines 10-11):
if(time.limit %in% c(NA, NaN))
time.limit <- 10 # or any minimal number
There's surely other ways to go about this. But this being a game programmed for fun, I'll happily go with that patch. Hopefully this can be of help to someone down the road and I won't have wasted 50 precious rep points in vain for that bounty! :D

Resources