Open tidyverse on Virtual Machine command line - r

My colleague and I are trying to run an R script on a virtual machine we both have access to. We're trying to run it in the command line of the virtual machine (long story, task scheduler etc..), and the actual script lives in a Onedrive location we both have access to (if you wonder why the file paths look different, its the same file location in each, different mapping).
I'm able to run the script and Tidyverse loads:
It runs into an unrelated error inside the script where it can't open a file, but that's not pertinent to this question. The relevant info here is that I can run it, and when it runs its able to successfully load Tidyverse
My colleague runs the exact same commands and receives this error:
It says that she can't load Tidyverse because there is no package called that.
We've both separately made sure that Tidyverse was installed. I.e. we'll be logged into the Virtual machine, we'll open RStudio and/or RGui (we've each done both) and install.packages("Tidyverse") and it'll install into this location for each of us:
So my question is:
Why does Tidyverse load when I run it, but not when my colleague does?

Related

How to execute an R shiny script from the command line

I've created a single R file 'myfile.R' which is composed of several functions, reading from an odbc connection, and of course the ui and server components for the shiny application. The goal is for the user to treat this as an executable, that is, I'd like them to be able to run this app without having to run Rstudio. Currently on this environment, Rstudio is installed (as are the relevant packages), what I'm currently writing in command line is:
Rscript myfile.R
The file looks to be successfully loaded, but the application itself does not 'pop up' towards me, infact nothing does, it just says that it is listening on http....
I was thinking of creating a bash script that could do this, and this seemed to be the most simple approach but this is not working.

Workflow for using command line R?

I am used to using R in RStudio. For a new project, I have to use R on the command line, because the data storage and analysis are only allowed to be on a specific server that I connect to using ssh. This server doesn't have rstudio-server to support remote RStudio sessions.
The project involves an extremely large dataset, and some pre-written code to load/format the data that I have been told to run using "source()" before I do anything else. This takes several minutes to run and load the data each time.
What would a good workflow be for something like this? Editing my code in a .r file, saving, then running it would require taking several minutes to load the data each time. But just running R in an interactive session would make it hard to keep track of what I am doing and repeat things if necessary.
Is there some command-line equivalent to RStudio where you can have an interactive session but be editing/saving a file of your code as you go?
Sounds like JuPyteR might be your friend here.
The R kernel works great.
You can use it on a remote server either with exposing an open port (and setting up JuPyteR login credentials)
Or via port forwarding over SSH.
It is a lot like an interactive reply, except it holds state.
And you can go back and rerun cells.
(Of course state can be dangerous for reproduceability)
For RStudio you can launch console and ssh to your remote servers even if your servers don't use expensive RStudio for servers platform. You can then execute all commands from R Studio directly into the ssh with the default shortcut key. This might allow to continue using R studio, track what you're doing in the R script, execute interactively.

R automatic task scheduling in windows: how to use external functions

I have a scheduled task in windows to run a R program ("ftp.R")
After many attempts and reading many SO literature, I found that the only way to make it work properly was writing this piece of code into a .bat file:
#ECHO OFF
RSCRIPT ftp.R
Everything goes fine except wqith it, when I am trying to use functions that I have in other R programs.
For example, in the "ftp.R" program I have this pice of code:
source("//BCN-01/Server/R/Main/Production/Check_Integrity.R")
In the "Check_Integrity.R" program I have some functions I need to use in "ftp.R".
The thing is that if I execute the .bat file manually, there is no problem, and the "ftp.R" runs perfectly. But if I run exactly the same .bat file but from the task scheduler the "ftp.R" is unable to find the external functions.
(I am running the code in a Windows Server 2012)
One big difference between running a batch manually / with the scheduler is that the scheduler starts the script with system32 folder as work directory. So it might be enough to add the following line to your batch file: CD %~dp0.
Another point is that the scheduler runs your batch as a different user. So it is possible that you (your user account) has access to //BCN-01/Server/R/Main/Production/ while the system user the scheduler is running your script with does not. You could also try to tell the scheduler to run the script with the same user which you are logged in when running it successfully by hand.
Finally I figured out what was wrong:
All the paths have to be defined as absolute paths: mapped units are not valid.
Althought I already I knew that (thanks to some posts I read here in SO), I missed one path mapped into one of the functions in 'Check_Integrity.R' .

Modifying R packages (snow)

Can anybody give me some direction on editing source code of an R package? From what I've seen, changing the package from within R does not seem to be possible. In editing outside of R, I'm stuck at unpacking the tar.gz. While I can now modify the function to my heart's content, the folder looks nothing like the working snow library. I presume I will need to turn the contents into a tar.gz once again and install it in the standard way?
My colleagues and I have been attempting to get makeSOCKcluster() to work with remote IPs for the past three days. Hangs indefinitely. After digging into the snow package I've found the issue to be in the way newSOCKnode() calls socketConnection(). If I run makeSOCKcluster("IP", manual=T) and then put the output into powershell, it results in the connection being made but the program not completing. However, I can run makeSOCKcluster("IP", manual=T) in one R instance and then run system("output", wait=F, input="") in another instance which results in the program completing. I believe I can simply modify snow to do this automatically.

Automatic network Installation

Recently I have been attempting to install a software package automatically over a moderately sized computer network for a university lab. The package is aspenOne v8.4. I have tried creating response files, but every time I finish the install I am unable to locate the response file. I included the f1 flag option to specify file location and name, and I have also checked the %systemroot% directory as well, to no avail. I do not believe one is being created. I have also tried creating a response file for the msi package included on the disc with msiexec, but I was unsuccessful in that path as well. The install requires too much time to install manually across the network, so I was hoping there might be another option to automatically deploy the application package throughout the network. Is there a way to do this?
Thank you in advance.

Resources