Create Graphs and Plots Using R in Microsoft R Server - r

I am going over 'Create Graphs and Plots Using R (Data Science End-to-End Walkthrough)' procedure.
Please check link https://msdn.microsoft.com/en-us/library/mt629162.aspx
I have issue with step 'Create a Map Plot', when executing:
myplots <- rxExec(mapPlot, inDataSource, googMap, timesToRun = 1)
plot(myplots[[1]][["myplot"]])
I am getting error:
Warning: namespace 'CompatibilityAPI' is not available and has been replaced
by .GlobalEnv when processing object 'inputObject'
====== DESKTOP-PHAA5KQ ( process 1 ) has started run
at 2017-01-24 11:39:07.56 ======
Warning: namespace 'CompatibilityAPI' is not available and has been replaced
by .GlobalEnv when processing object 'inputObject'
Loading required package: ggplot2
Loading required package: maps
# ATTENTION: maps v3.0 has an updated 'world' map. #
# Many country borders and names have changed since 1990. #
# Type '?world' or 'news(package="maps")'. See README_v3. #
Error in slot(from, what) :
no slot of name "maxColWidth" for this object of class "RxSqlServerData"
Calls: source ... anyStrings -> validityMethod -> as -> asMethod -> slot
Execution halted
Error in rxCompleteClusterJob(hpcServerJob, consoleOutput, autoCleanup) :
No results available - final job state: failed
> plot(myplots[[1]][["myplot"]])
Error in plot(myplots[[1]][["myplot"]]) : object 'myplots' not found
Thanks in advance for any suggestion.

I think this is a version issue.
This question gave me some context. Your IDE or client may not be using the same version of R as R-Services.
Check the version of R in your IDE and R-Services using:
R.Version()
For R-Services, navigate to C:\Program Files\Microsoft SQL Server\MSSQL13.YOUR_SERVER_NAME\R_SERVICES\bin then run R.exe as admin.
You might see that the versions are different. In my case I was running 3.3.2 in RStudio but have 3.2.2 in R-Services.
For RStudio, here's how to use different versions of R. Starting RStudio with the Control key held down allowed me to select the R-Services instance and run the code successfully.
You can also change your default library path so that whenever you open your IDE you're working with the server's version of R.

In my case both R services and R studio had same version. And the error message was ggplot2 is required by ggmap. For my solution I uninstalled both ggplot2 and ggmap, Closed R studio and reopened it with administrative rights.

Related

R: "internet routines cannot be loaded" when starting from RStudio

I am running Red Hat Enterprise Linux (RHEL) 8.5 with Linux kernel 4.18 and Gnome 3.32.2. In this system, I've got R 4.1.2 compiled with the tool asdf with shared libraries enabled. On top of that, I installed RStudio 2021.09.01-372 from an RPM from the official RStudio website.
When I start Rstudio, the first line of output after the usual R startup is an error:
Error in tools::startDynamicHelp() : internet routines cannot be loaded
I am unable to figure out what's causing this error, and with it I can't run things like refresh CRAN or update packages. But if I start a pure R session from the terminal (instead of Rstudio) this error does not occur.
Some things I tried:
Install the krb5 and libssh2 packages on my host system: Didn't help.
Starting a "pure" R session (both with and without the --vanilla argument) from the Terminal tab within Rstudio also gives this error. If I try to run update.packages() from this session, it pops up a window to select a CRAN mirror then fails with the following:
Warning: failed to download mirrors file (internet routines cannot be loaded); using local file '/home/[my username]/.asdf/installs/R/4.1.2/lib64/R/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cloud.r-project.org/src/contrib:
internet routines cannot be loaded
Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object '/home/penyuan/.asdf/installs/R/4.1.2/lib64/R/modules//internet.so':
/lib64/libssh.so.4: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b
But like I said, the strange thing is if I start an R session outside of Rstudio, these errors don't happen.
Within RStudio, the only workaround I can find is to run this command upon startup (suggested in this thread):
options(download.file.method="wget")
Once this is done, everything else seems to work, such as package updates.
However, I don't want to manually do this every time I start RStudio. So I tried to put it into ~/.Rprofile including a test print() as follows:
print("This is `~/.Rprofile`")
options(download.file.method="wget")
When I open RStudio, I can see the output from the print() call, but the options() command is not run because the original error shows up again. I still have to manually enter options(download.file.method="wget") every time.
I also tried to fold everything into a .First function in ~/.Rprofile as follows:
.First <- function() {
options(download.file.method="wget")
print("This is the `.First` function in `~/.Rprofile`")
}
Unfortunately, same result as before: print()'s output is seen, but options() is not run.
I also made sure that my ~/.Rprofile includes a trailing newline as discussed here. But this didn't help.
The above are the steps I've tried so far.
Why does this error only occur when running RStudio or a terminal within Rstudio? Why doesn't it happen if I start R from a terminal outside of Rstudio?
Is there a way to solve the problem so that the error doesn't happen in the first place? If it can't be solved, how do I set up my ~/.Rprofile so that options(download.file.method="wget") will be run?
Thank you.

how can fix this issue "Error in h2o.upload_model() : could not find function "h2o.upload_model"?

I have installed h2o package(in R from RStudio console). Post h2o.init() I am trying to use the built in function upload_model()/upload_mojo() but I am getting following error.
h2o.upload_mojo()
Error in h2o.upload_mojo() : could not find function "h2o.upload_mojo"
h2o.upload_model()
Error in h2o.upload_model() : could not find function "h2o.upload_model"
I found work around to resolve this issue. Please find below the steps I followed:
Remove the package using: remove.packages("h2o")
Quit the current session and launch the new one.
Move out lock file for h2o from path where package was installed mostly under R with file name like - 00LOCK-h2o
Install new/latest version of package via RStudio console using install.packages()
It should now resolve this issue.

Error in x[[method]](...) : attempt to apply non-function in testthat test when sourcing file

I am developing an R app and came up with a workaround to integrate testthat in it (it usually requires your project to be a package) by adding a DESCRIPTION file to the project root.
I got this method from a colleague who managed to get it to work like this.
The problem is, when I try to test anything (even empty test files), I get this error:
Error in x[[method]](...) : attempt to apply non-function
Calls: <Anonymous> ... <Anonymous> -> o_apply -> lapply -> FUN -> <Anonymous>
Execution halted
What I know is that this appears only on macOS. My colleague can still run this app without problems on Windows.
What's the deal with it?
The MCVE for reproducing this error would be:
create a minimum DESCRIPTION file with content:
Package: testpckg
add testthat to your project:
usethis::use_testthat()
usethis::use_test("foo")
create empty file bar.R
in test-foo.R, source bar: source("bar.R")
RStudio Version 1.1.447,
R version 3.4.4, Mac OS X 10_13_4
This appears to be due to a bug in testthat 2.0.0. Adding a context("Name of test context") to the top of each test file worked for me (tested using Ubuntu and Windows).

Using RStudio's "Build" but no *.Rcheck generated

I've just started using RStudio's build check, and used it to make one package already. I've started on a second package, and this one is failing. As the build attempt happens, I get updates like:
* checking whether package ‘< package >’ can be installed ... ERROR
Installation failed.
See ‘/home/user/git/< package >.Rcheck/00install.out’ for details.
* DONE
Status: 1 ERROR
The problem is that the defined folder < package >.Rcheck doesn't exist, and neither do the files that are supposed to be in it (i.e. 00install.out, and 00check.log). Also, where I write < package >, the actual name of my package is shown instead.
I had folders view visible while the package was building, and I saw the .Rcheck folder appear, and then disappear shortly after. I was even able to browse the 000install.out file, but it had not yet encountered any errors.
It appears that the whole Rcheck folder is being removed when the build fails, leaving me with no trace of what caused the error.
Has anyone else experienced this? I'm using RStudio version 0.99.902 with R version 3.3.1 on Arch Linux.
My approach is the following one:
Go to 'Tools' -> 'Global Options' -> 'Packages' and then have a look, if 'View Rcheck directory after failed R CMD check' is ticked. You find other useful options there, too, e.g. 'Cleanup output after successful R CMD check'.
A little more detail on how to preserve error logs, based on the answer from #J_F. I needed to tick View Rcheck directory after failed R CMD check, because the cleanup occurs after the misleading message
See
‘.../yourpackage.Rcheck/00check.log’
for details.
I also needed to untick Cleanup output after successful R CMD check, because R CMD can succeed even when there are errors!
R CMD check results
1 error | 3 warnings | 2 notes
Warning messages:
1: `cleanup` is deprecated
2: Version of roxygen2 last used with this package is 6.0.1.9000. You only have version 6.0.1
R CMD check succeeded

rbundler build error: "cannot open file 'startup.Rs': No such file or directory"

I'm running into an issue when building the following package: https://github.com/yoni/rbundler
My test attempts to run rbundler's bundle command on a trivial package which has a single dependency. The test passes on my OSX machine, but fails on my x86_64-redhat-linux-gnu Jenkins server. Both machines are running R 2.15.1 with devtools 0.7.1, which includes this bug fix.
The full test output can be found in this gist.
Here's a short summary of error I'm seeing:
Error in file(filename, "r", encoding = encoding) :
cannot open the connection
Calls: local ... eval.parent -> eval -> eval -> eval -> eval -> source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
cannot open file 'startup.Rs': No such file or directory
Execution halted
The background for this is that I'm trying to build a dependency management system for R. The idea is that an R project should be able to run without using system-wide or user-wide libraries. Rather, the R project will have it's own library installed under it's root directory.
For my previous Stack Overflow question related to Dependency Management in R, see Dependency management in R
In my case this issue was caused by the environment variable R_TESTS that was set to startup.Rs
When you execute another R process from within your tests (in my case it was submitted via OGS qsub), the presence of this environment variable causes issues.
I can't answer your question directly, but two things you can try get more information about what is happening.
use 'env' to dump environment variables on your OSX machine and the Jenkins host
run the process through strace on Linux and dtruss on OSX to trap the system calls
strace/dtruss should reveal the places in which it is searching for startup.Rs and env output will likely give you a environment variable that differs between the system accounting for the different outcome.

Resources