Run R (from pkg) in terminal on OS X - r

I just installed MacOS version of R from the CRAN web site. Within the R GUI application, everything works fine. However, I'm unable to run it from terminal. Trying to trigger R or Rscript in terminal yields a message indicating that neither command exists.
Also I do not see corresponded scripts in /Applications/R.app/Contents/.
How can I run R from terminal?
PS: I know brew installation will help. But I want this version of R from CRAN web site.

The R installer creates /Library/Frameworks/R.framework/ directory in addition to /Applications/R.app/.
So, you need add a correct directory to the Library dir. For my packages:
R_APP_DIR=/Library/Frameworks/R.framework/Versions/3.2/Resources/
export PATH=$R_APP_DIR:$PATH

Related

Running R from Excel using specific old R packages

First time question asker.
I created an Excel/R tool that uses:
Excel VBA to create a CSV file with data for R,
Launch R using a Windows Shell,
Detects when R is finished running and then
Imports the results in a CSV file created by the R script.
Unfortunately, the R code does not work as programed with some package versions created after 3/1/2020, which creates problems for new users because they cannot just install the current package versions or users who want to use conflicting versions for other projects.
I have a solution for users who do not require newer versions of R for their other work; writing a script that installs all the packages and their dependents using the “versions” package. However, I think this approach will constrain users who want to use newer versions of R. **Is this a correct assumption? **
I thought the {checkpoint} package might offer a good solution. I can get it to run in well in RStudio by creating a RStudio project (where I ran the {checkpoint} package to install the 3/1/2020 versions of my packages). However, I have not found a way to run the R script from the Windows Shell. The R script does not seem to be able to access the packages installed in the RStudio project using {checkpoint}. Does anyone have ideas of how I can have Excel VBA launch the start of the R script in a way that it can assess the packages installed in the RStudio project by {checkpoint}? Perhaps there is a Windows Shell call for RStudio similar to the one I use now for R?
Here is the Windows Shell code I currently use for R in case it helps. It works with the versions approach but not the {checkpoint} approach.
rExeCall = "C:\Program Files\R\R-3.6.2\bin\Rscript.exe"
rExeOptns = " --no-environ --no-init-file --no-restore --verbose "
rscrpt=”Tool.R”
Shell (rExeCall & rExeOptns & rscrpt)
Thank you in advance for your help!
I had hoped that my current R shell code would work when I used {checkpoint} to install the correct versions of the packages in an RStudio project.
I tried specifying the .libPaths to the file location for the RStudio projection (per Running R script from PHP in VSCode not recognizing R packages) without success.

How to install RGui to update R version

This may be an odd question: where do I find RGui?
I want to update my R-version from 4.1.2 to 4.2. I found this website which uses RGui. However I cannot find a RGui in my Windows Start Menu and searching the web yields this.
I believe I have to install any RGui and run the installation commands, is this correct? If so, can you recommend a software?
Rgui comes with R. There is nothing extra to install to run it. You do not need RStudio in order to run Rgui. RStudio is a front end to R that is separate from Rgui and is an alternative to Rgui . Unlike Rgui, RStudio does not come with R.
To get a desktop icon, run the R installer again and make sure you have the item checked for a Desktop Icon.
To locate Rgui.exe try this from the Windows cmd line assuming R is installed in the standard location.
cd C:\Program Files\R
dir /b /s Rgui.exe
Also if Rgui is already on your path then running this from the Windows cmd line should find it.
where Rgui.exe

How do you run an R script from Windows command line with only RStudio installed?

I have a machine that only has RStudio installed. It does NOT have Rscript.exe which is how I normally run R code from the Windows command line.
How do I run R code from the command line on a Windows machine that only has RStudio installed? They can NOT install the normal R runtime so I need something that comes with RStudio.
Thanks!
Rscript is a scripting front-end, which calls for and uses R. You cannot make successful calls to R without having R. If you just have Rstudio you will not be able to run R since it is assumed that you install R.
Use the portable version of R if you do not have admin privileges.

Which runtime is getting referenced

I have installed R at following location C:\E_Drive\ProgramFiles\R-3.4.3, so I think R environment installed at C:\E_Drive\ProgramFiles\R-3.4.3 will be used when I run the R console, right? Please correct me if I am wrong.
Now, I install a package using the R console.
Now, I download and install RStudio and from the R console of RStudio if I check whether that package is available or not then I see that it is available. I am wondering, how RStudio's R console reported that package is available, I didn't expect that since C:\E_Drive\ProgramFiles\R-3.4.3 is not on my PATH and in no way is linked RStudio with C:\E_Drive\ProgramFiles\R-3.4.3, so I thought RStudio would be referring its own R environment.
Can you please help me understand how my RStudio is referencing the C:\E_Drive\ProgramFiles\R-3.4.3 R environment.
R normally installs packages in the same directory tree as its own binary, but it can also install them elsewhere. On Windows, this generally happens because regular users often don't have write permission in the Program Files directory. The standard Windows installer also records R's location in the registry, so that it doesn't need to be on the PATH to be found by RStudio.
You can find out where Windows or RStudio found R by running R.home() within R. You can find out where R is finding packages in a particular session by running .libPaths().

Rscript pointing to incorrect R version in local build

I recently installed a local version of R 3.1.0 on a Linux Redhat server as follows:
# from R-3.1.0 directory
./configure --prefix=$(pwd)
make
make install
In addition, I've updated PATH and R_LIBS in my .bashrc. If I run path/to/local/R/bin/Rscript --version, then it returns the proper version number. However, if I give it a test script that prints sessionInfo it yields information from the system-wide R installation.
Is there any more I need to do to run the local version of R using Rscript? From reading a similar issue here, it looks like the code above should be all that's necessary. There's a similar SO issue here, but it's unresolved.
Edit:
I just fired up Ubuntu in a VM and was able to install R locally and run Rscript without problem (using the same commands listed above). Have I gone crazy? Is there anything that might be floating around the Redhat environment on this server that might mess up the installation? Sanity checks?

Resources