R-Studio setup with offline CRAN repository in Windows - r

I would like to know what is the mchanism, if there is one, for setting up local CRAN repository in an environment that has no internet access. I have a windows environment but I would love to know if it can also be done in linux environment.
I have heard that I'll need to have a web browser to allow R-studio to find local repository. Not sure if it's true but I would like to find out all the steps to set this R-studio with local repository environemnt.
The idea is to have a fully fuunctional R-studio with full CRAN respository available in an offline environment where any package can be installed easily. I couldn't find any source/link available online that details how this can be achieved.
I know R-Studio is setting a package management tool that allows this functionality but I would like to get this done without spending any money.

I managed to solve this problem by creating a local webserver using Apache and then downloading full CRAN repository (win binaries only). I also had to edit my Rprofile.site file by providing the link to my local webserver.

Related

Best (standard) way to deploy the libraries for a shiny app to the shiny server?

I'm trying to get a shiny app deployed on Shiny Server. I can do that without any issues, but when trying to deploy an app that has a number of dependencies (remote and local) we keep running into issues.
We used renv to track the dependencies (on the Windows dev box) and rebuild it from scratch on the Linux prod box, but even though the dependencies are rebuilt and some get loaded, others do not. The .Rprofile of the user running the app is pointing to the renv activation script.
For the sake of clarity, we need and want all the R code to be built from the source code on the Linux box.
What is the best or standard way (or even a poor way that works) to deploy the libraries for a shiny app to the shiny server? Is renv even the right tool for this scenario or is there a better tool?
I've tried reading the shiny server documentation and the closes it only mentions that it uses the .Rprofile of the user running the app, but there doesn't seem to be any sort of guide on the best way to deploy dependent libraries.
This renv documentation discusses some reproducibility caveats:
system dependencies, and
changes in CRAN (e.g. a binary no longer being available).
Since you are moving from a Windows to a Linux system your packages may have unmet system dependencies (things that need to be installed outside of R) that you didn't encounter in Windows. For example, rJava is required for some of the Excel-related R packages, and getting its related system dependencies installed and working on Linux can sometime be a challenge. You can use the RStudio Package Manager Website to figure out what system dependencies are required for different R packages for your particular Linux OS. Also, the error messages you get when running these apps on Linux should point you in the right direction. These system dependencies are what you'll have to manage yourself since renv doesn't.
But for a more production-level solution you can try Docker and ShinyProxy. For apps with many dependencies or especially external dependencies (e.g. Python, SQL, etc.) you can guarantee more reproducibility using Docker. ShinyProxy can be used to host apps built into docker images. This is more work, but you ensure the entire system is reproducible, not just the R version and R packages. ShinyProxy also adds additional hosting capabilities like user authentication.

Packrat::restore() for system dependencies

I was developing a shiny-app on a Windows machine in Rstudio. Now I need to develop it on a Linux machine and later on will need to deploy it on a server. Because of the need to run the app across platforms, I was looking into some environment control application so that I don't have to tune and reinstall the needed packages manually.
I tried to use Packrat for this purpose. I made a snapshot on my Windows machine, copied and pasted the project to my Ubuntu, reopened the project on RStudio, installed Packrat and the restore of the packages ran automatically. Then I ran into an issue that some of the packages that requires system dependencies were not installed automatically, e.g. rgdal and jqr. Therefore, I had to manually install those system dependencies manually in a terminal (it took me a while because there were about 10 of them that requires extra system dependencies).
I am wondering if there is an easier way to just automatically handle this. Later on, I will need to work with a system administer to deploy the app to the server. I am wondering if Packrat has the capability of automatically installing system dependencies on Linux machine/server. If anyone has encounter this issue before, or have other better options, please let me know!
Thank you!
Hello and welcome to StackOverflow.
You are facing a question that is actually much harder to tackle than you may think at first---deployment of complex R package dependencies across different operating systems is a truly hard and, truth be told, unsolved problem!
You can of course use packrat and renv for R package dependencies and snapshots of particular versions. But this does not do anything for system-level dependencies which are simply taken as "given". So no to just transfering to another box and saying "abracadabra". Sorry!
The closest we all may have gotten to fixing this may be Docker where you can create a portable unit of execution that can be deployed whereever Docker run: Windows, macOS, different Linux flavours, ... as it encodes everything.

Installing atom packages with dependencies whilst offline

I've just joined a new office and their security is very tight. Essentially, we cannot go online without connecting to another machine. This means any applications that attempt to connect online won't connect to anything.
I'm trying to set up atom for python development (I've not used atom before and it's all that available to me!) - but the lack of internet is causing an issue.
I understand that to install a package, I can download it from github, and extract it to ~/.atom/packages - and this works! But what do I do with packages with dependencies that haven't been downloaded? Is there a simple way to get the package and the dependency whilst being offline?
I've also noticed that although my office has atom installed there's no 'apm' or 'npm' commands in the terminal...is this common?
thanks

R - Add custom packages to cloned version of CRAN

At my company we have a server where we host, for internal use only, a clone of CRAN (refreshed only when new versions of R come out). We do this to allow internal servers to install packages from R without needing internet access and it helps ensure that everyone at the company is always using the same version of packages (or can easily update to get caught up).
Recently we've been making some custom internal packages. This tend to be convenience wrapper packages built explicitly around our systems, they would be of zero use to anyone outside our company so I don't want to try and submit them to the official CRAN.
How do I 'submit' them to our cloned CRAN so they can be installed via install.pacakges('blahblah') instead of me having to email out copies of the packages and upload them to each server?
You want drat to inject packages into a repo -- any repo -- and drat does not care if your repo is a 0% or 100% clone of CRAN, or anywhere in between.
A repo is still just a repo: a collection of source tarballs [and maybe binary packages if you have the (mis)fortune to rely on Windows too] and you simply need to update the PACKAGES files.
We run a local repo at work with our very much non-public packages for the same reason.

Building R package for windows on mac

Question:
I am developing an R package. I have not yet submitted to CRAN (and it's not ready to at any rate). I want to send the package to friend for some preliminary testing (he's not a builder) and I just want to see if he can use a few features.
On my Mac version of RStudio, I can generate binaries easily. It creates a file called "iatgen_1.0.tgz"
Can my friend use that to install my early build on his windows machine? Or do I need to do something to that file to make it usable for a windows user. Let's assume I have NO access to a windows machine. What can I do from my mac to make this package usable by windows users?
I am posting my comment as an (extended) answer because I think it will help you. When I built my package, I did not have access to Windows either and was suffering from the same issue. I discovered the the Windows build service offered at http://win-builder.r-project.org/ and it worked great. You'll need to do a few things before you send it in, and this is all explained on the site.
First, build your source package with R CMD build. Next, check the package with R CMD check. If this succeeds, follow the rest of the instructions on the site and if all goes well they will send you a link to the temporary directory on their server where you can download the Windows build. If all does not go well, Mr. Ligges will send you an email with the detailed issues so you can fix them and try again.
Like I said, the service worked very well for me. The response was prompt and there were absolutely no problems.

Resources