Setting Proxy in R and windows for Leaflet Package - r

I usually don't have trouble downloading packages and using them currently in my office but I do have trouble accessing some API's and using Leaflet (map does not render)
these things work while I am off the network but I wish to use my works proxy which I have the IP and user/pass but Can't get it to work on Windows.
So far I have tried the following with no success:
Sys.setenv(http_proxy="http://user#ip:8080/")
Sys.getenv("http_proxy")
This returns the proxy but does not allow leaflet maps to render still.
I managed to get this proxy to work in Python when installing packages with the following in the Terminal:
pip install mpld3 --proxy=http://user#ip:8080
Any help is appreciated.

Try the following:
setInternet2(FALSE)

Related

R connection via Proxy

I am working in a Windows on-premise server which needs a proxy to establish network connection. I have installed R (4.2.0) and now I need to install some packages. However, every time I try to run the command install.packages("dplyr") for instance, I got an error like:
cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
I have looked for some suggestions and what I find most is to define the environment variables http_proxy or https_proxy. I have tried to put http_proxy="http://someproxy.aaa.aa:1111/" in the Rprofile file (or directly in the console with Sys.setenv) with or without user:password but I get always the same error.
I wonder if the call is using those proxy settings since it never affects the outcome. I am not even sure if I am setting correctly because the error message is always the same.

Cannot configure rgee R package properly with ee_install()

I've searched for tutorials to help configure the package in my PC, and I've found this one: https://www.youtube.com/watch?v=_fDhRL_LBdQ
I executed every part of the code interactively with the tutorial, but when I run ee_install() (after installing miniconda with py_discover_config() and other packages previously, such as reticulate), but it keeps me returning an error saying that anaconda is mandatory for the package since I'm a windows user.
Here is the error I get:
Error in ee_install_set_pyenv_env(py_env = py_env, py_path = python_path, : Windows users must install miniconda/anaconda to use rgee. The use of a Python environment is mandatory.
I've just installed Anaconda (full version with navigator) and I set a new python environment called "py2r" and tried to use the function ee_install_set_pyenv(), passing the path to the environment created through Anaconda Navigator (which has a python.exe) as paremeter to py_path and the name "py2r" as paremeter for py_env arg. And yet, it didn't work.
What am I missing?
In case you want to take a look at the code, I can provide it, but I don't think it's necessary because is a simple test script that follows as I described.
Thanks for your attention and congratulations for the library, it will be very usefull for me at work!
I fixed the ee_install() problems bypassing them and doing every passage manually. It will require no more then 10 mins and you will probably fix the installation problems. You can find and follow the manual installation with this tutorial:
https://www.youtube.com/watch?v=1-k6wNL2hlo

How to install Julia kernel for Jupyterhub

I'm trying to make julia language available through jupyterhub on an ubuntu server.
I already have installed and configured the jupyterhub. Its working fine with python3.5.
And the authentication method is Regular Unix users and PAM.
I installed the julia language in /usr/local/julia-1.0.2/ and it is available for all users globally.
then with the root user I set the JULIA_DEPOT_PATH="/usr/share/juliapackages/
then again with the root user, I run the julia and run the
using Pkg
Pkg.add("IJulia")
it installs the IJulia in the specified path.
from this point, I didn't find any further useful instructions on the internet over the subject of installing julia kernel for jupyterhub, so I don't know how to proceed.
does anybody have a good step by step document to find the solution?
I followed the instruction proposed here but it seems doesn't work for me.
As you are using Jupyterhub, the best way would be to use a docker spawner and use the data science docker image which has Julia already installed and configured.
https://github.com/jupyter/docker-stacks/blob/master/datascience-notebook/Dockerfile

Getting auth sign message when connecting cloud server using opencpu

I am trying to expose a sample r model as API so I created R package. In my local machine , I am able to get the output using the command :
curl http://local host/5656/ocpu/library/mypackage/R/tv/json -F "input=#test.csv"
But when I am trying the same in my AWS linux cloud server on CentOS , I am not getting the output. I tried the command :
curl 13.228.109.233:8787/p/5656/ocpu/library/mypackage/R/tv/json -F "input=#test.csv"
and I get the output as
http://13.228.109.233:8787/auth-sign-in?appUr‌​i=%2Fp%2F5656%2Focpu‌​%2Flibrary%2Fmypacka‌​ge%2FR%2Ftv%2Fjson .
The R package is loaded into the my R studio server and I am trying to access it using putty. I installed the open cpu using the command :
yum install opencpu-server
It looks like it is asking for some authentication but I am not able to get what it means. Am I missing something here?
Thanks
If one visits the URL with a browser, one sees the RStudio-Server login screen. And indeed, you are connecting to port 8787, which is the default port for Rstudio Server. Try URLs below http://13.228.109.233/ocpu/ instead.
As Ralf suggests, that was the error , I was giving the wrong URL . Also, whenever we install opencpu in CentOS , just doing a 'yum install opencpu-server' might not be sufficient. We need to execute the entire built script: https://github.com/opencpu/opencpu-server/blob/master/rpm/buildscript.sh
Without executing the build script , I was not able to connect to opencpu server.
Just in case someone gets the same issue.

R built in Web server

Since R 2.13, R comes with a built-in web server.
Is there a simple way to create a local web server using R with a custom port number?
In python it will be (to use "http://localhost:8080") :
python -m SimpleHTTPServer 8080
I'm aware of Rook but I look for a simple solution.
Take a look at Rook - it's on GitHub. About setting a port number, see ?tools::help.ports it accepts a vector of numbers (integers) and it will choose the first available one. There's also sinartra (CRAN, GitHub), but I'd rather go with Rook.
It looks like servr might be what you're looking for these days.
From github:
To some degree, this package is like python -m SimpleHTTPServer or python -m http.server.
https://github.com/yihui/servr
https://cran.rstudio.com/web/packages/servr/index.html
Example code
writeLines("<h1>Hi</H1>", "index.html")
# install.packages("servr")
library(servr)
servr::httd()
# createTcpServer: address already in use
# To stop the server, run servr::daemon_stop(2) or restart your R session
# Serving the directory /Users/st/R/localhost at http://127.0.0.1:7826
Place the address in the browser: http://127.0.0.1:7826
This is not an answer, but some places to get started.
If we run R from terminal (by typing R), then run help.start(), it will start a local host and open it in the browser. On mine, it opens http://127.0.0.1:16371/doc/html/index.html. This at least proves that it's possible to open a localhost in R without any external packages.
I have found some of the code that makes this happen in the R Source Code.

Resources