I am trying to use RStata in order to run Stata from R. I first did:
options("RStata.StataVersion" = 14)
That didn't cause an error.
But I also need to set the binary path. I have a Mac, and Stata is contained in a folder in the Applications folder. Here is what I have tried:
options("RStata.StataPath" = "/Applications/Stata/Stata")
Unfortunately, this causes an error. What should I do?
With no knowledge of RStata, I can say that on macOS 10.12.6 with Stata/SE release 15 installed, in the terminal window
open /Applications/Stata/StataSE.app
is what's required to launch Stata. It is possible that in looking for the Stata executable, your Finder Preferences does not have "show all filename extensions" set in the Advaced pane, so you weren't shown the .app extension.
From the README, better rendered here
Mac users are a notable group: at this stage they should set the path
for the command line executable (not the GUI app). Eg for a Stata13 SE
installation in El Capitain (with default options) the path is
'/Applications/Stata/StataSE.app/Contents/MacOS/stata-se'. In other
cases (Stata licenses, installation path and so on) the path could be
slightly different (BTW, i've found the path 'exploring' the
filesystem with a terminal, not the graphics explorer since it 'stops'
at 'StataSE.app').
(yes, putting something in the manual as well is in my TODO :) )
hth, best, Luca
Related
I use a separate installation of R for each project.
To make RStudio use the right one I click and hold down the Control key when I start RStudio.
This opens a "Choosing R Installation" pop-up where I can select the R binary I need.
The problem is that - unlike in this RStudio support article - the pop-up shows only the very last version of R that I used.
So whenever I switch projects I have to browse to the R binary that I need.
Is there a way to make RStudio remember the other R versions I've used?
If there isn't, where does RStudio look for the last used one? If I knew that, I could probably use a script to overwrite it before launching RStudio.
Some details:
I am on Windows 7/10.
RStudio version is 1.3.1093
None of the registry keys described here are set.
Since you mentioned that you kept the registry clean and under the assumption that you are using distinct/separate folders for each of your projects one COULD be tempted to try something like
a .Renviron file containing R_HOME=C:/path/to/your/required/version or
a .Rprofile file containing Sys.setenv(R_HOME='path/to/your/version')
in your project folder(s)?
Or potentially put a .bat file in there with content like
SET R_HOME=Path/to/your/R.version
cd /D "%~dp0"
start .YourProject.Rproj
BUT NOPE!
Currently this type of functionality/behaviour is NOT available for RStudio Desktop Free (as of time of writing this is RStudio Desktop 1.3.1093) BUT can only be achieved with RStudio Server PRO - see 6.3.3 User Configurable Default Version.
#Evgenil: updated answer based on your suggestion and after I had the time to test the idea as well
I had a similar problem. The way I solved this was by utilizing portable versions of R and RStudio.
To get this to work I needed a few things.
Download portable versions of R, https://sourceforge.net/projects/rportable/files/
Download portable versions of RStudio, https://sourceforge.net/projects/rportable/files/
Download IniFile 1.92, https://www.horstmuc.de/wbat32.htm#inifile
In this example I have created three folders on my desktop.
BatchSetRandRStudio, R-Portable-4.1.2, RStudio-2022.02.3-492
Example steps:
Create a folder to house the batch file that will launch R and RStudio. e.g. C:\Users<username>\Desktop\BatchSetRandRStudio.
Place the downloaded IniFile, inifile.exe, in the folder you just created for the batch file.
Create a batch file with the example code below and change the paths to your specifications for the portable versions of R and RStudio. e.g. Batch4.1.2RLaunchRStudioRun.bat
#echo off
REM Remember to update the Rprofile.site within each R-Portable location, in the etc folder for each portable R version:
REM C:\Users\<username>\Desktop\R-Portable-4.1.2\App\R-Portable\etc
REM .First = function(){
REM .libPaths(.Library)
REM }
REM Also the portable R library location is located:
REM C:\Users\<username>\Desktop\R-Portable-4.1.2\App\R-Portable\library
:: INI editor; inifile.exe needs to be in same folder of batch file to work
:: Source: https://www.horstmuc.de/wbat32.htm#inifile
:: INIFILE filename [section] item=string
:: inifile.exe "C:\Users\<username>\AppData\Roaming\RStudio\desktop.ini" [General] RBinDir=C:/Users/<username>/Desktop/R-Portable-4.1.2/App/R-Portable/bin/x64
inifile.exe "C:\Users\<username>\AppData\Roaming\RStudio\desktop.ini" [General] RBinDir=C:/Users/<username>/Desktop/R-Portable-4.1.2/App/R-Portable/bin/x64
:: FOR R 4.1.2
:: Start Program
:: start "" "C:\Users\<project folder>\Desktop\RStudio-2022.02.3-492\bin\rstudio.exe"
start "" "C:\Users\<username>\Desktop\RStudio-2022.02.3-492\bin\rstudio.exe"
:: FOR R 4.1.2
:: Start Program and specific project
:: start "" "C:\Users\<username>\Desktop\RStudio-2022.02.3-492\bin\rstudio.exe" "C:\Users\<username>\Desktop\R-Portable-4.1.2\Projects\<project folder>\<project name>.Rproj" & :: This command starts RStudio and opens specific project
Update the Rprofile.site file within each R-Portable location (allows one to have separate package installations for each portable version you create) with the following code:
.First = function(){
.libPaths(.Library)
}
Run the batch file, RStudio should open with the version of R you have pointed it to as well as the version of RStudio you have specified. You should be able to add projects and create specific batch files to open each project separately.
After having set the path for the default working directory as well as my first (and only) project within RStudio options I wonder why RStudio keeps creating an empty folder named "R" within my "/home" directory every time it is started.
Is there any file I could delete/edit (eventually create) to stop this annoying behaviour and if so, where is it located ?
System: Linux Mint v. 19.3
Software: RStudio v. 1.3.959 / R version 3.4.4
Thanks in advance for any hints.
Yes, you can prevent the creation of the R directory — R is configurable via a set of environment variables.
However, setting these correctly isn’t trivial. The first issue is that many R packages are sensitive to the R version they’re installed with. If you upgrade R and try to load the existing package, it may break. Therefore, the R package library path should be specific to the R version.
On clusters, an additional issue is that the same library path might be read by various cluster nodes that run on different architectures; this is rare, but it happens. In such cases, compiled R packages might need to be different depending on the architecture.
Consequently, in general the R library path needs to be specific both to the R version and the system architecture.
Next, even if you configure an alternative path R will silently ignore it if it doesn’t exist. So be sure to manually create the directory that you’ve configured.
Lastly, where to put this configuration? One option would be to put it into the user environment file, the path of which can be specified with the environment variable R_ENVIRON_USER — it defaults to $HOME/.Renviron. This isn’t ideal though, because it means the user can’t temporarily override this setting when calling R: variables in this file override the calling environment.
Instead, I recommend setting this in the user profile (e.g. $HOME/.profile). However, when you use a desktop launcher to launch your RStudio, this file won’t be read, so be sure to edit your *.desktop file accordingly.1
So in sum, add the following to your $HOME/.profile:
export R_LIBS_USER=${XDG_DATA_HOME:-$HOME/.local/share}/R/%p-library/%v
And make sure this directory exists: re-source ~/.profile (launching a new shell inside the current one is not enough), and execute
mkdir -p "$(Rscript -e 'cat(Sys.getenv("R_LIBS_USER"))')"
The above is using the XDG base dir specification, which is the de-facto standard on Linux systems.2 The path is using the placeholders %p and %v. R will fill these in with the system platform and the R version (in the form major.minor), respectively.
If you want to use a custom R configuration file (“user profile”) and/or R environment file, I suggest setting their location in the same way, by configuring R_PROFILE_USER and R_ENVIRON_USER (since their default location, once again, is in the user home directory):
export R_PROFILE_USER=${XDG_CONFIG_HOME:-$HOME/.config}/R/rprofile
export R_ENVIRON_USER=${XDG_CONFIG_HOME:-$HOME/.config}/R/renviron
1 I don’t have a Linux desktop system but I believe that editing the Env entry to the following should do it:
Exec=env R_LIBS_USER=${XDG_DATA_HOME:-$HOME/.local/share}/R/%p-library/%v /path/to/rstudio
2 Other systems require different handling. On macOS, the canonical setting for the library location would be $HOME/Library/Application Support/R/library/%v. However, setting environment variables on macOS for GUI applications is frustratingly complicated.
On Windows, the canonical location is %LOCALAPPDATA%/R/library/%v. To set this variable, use [Environment]::SetEnvironmentVariable in PowerShell or, when using cmd.exe, use setx.
I've been trying to automate some basic stuff with Robotframework. Here is my configuration.
Python - 2.7.10
MAC High Sierra 10.13.2
Eclipse Oxygen with RED Editor
I've downloaded Geckodriver executable and put in under several places including usr/local/bin, folder on desktop
Here is what i've tried
Setup FFDriver Set Environment Variable webdriver.gecko.driver Users/[my username]/Desktop/geckodriver
Setup FFDriver Set Environment Variable webdriver.gecko.driver usr/local/bin/geckodriver
and my test
open browser http://www.google.com firefox
I've added usr/local/bin in PATH as well and still getting "geckodriver executable needs to be in PATH" error. The same happens with Chromedriver too. I am sure I must be missing something trivial here, can someone help me out please?
Launching the eclipse from command prompt, has fixed this issue. Yes, the PATH is not being inherited when launched from desktop icon.
when you use Python. the best shortcut you can do is, put you 'geckodriver.exe' file in pythons script folder. and set the Script folder path in you system path. this will resolve your problem.
When running the checks for my R-package (via devtools::check()) I face the warning ''qpdf' is needed for checks on size reduction of PDFs. I found this question were it was suggested (if I understood the answer correctly) to run Sys.which(Sys.getenv("R_QPDF", "qpdf")) and see whether qpdf is found or not. In my case this just returns
qpdf
""
so, I think I didn't install qpdf correctly. Unfortunately it seems to be quite complicated to install qpdf on Windows. My first side question is: does it really is so painful and complicated to install qpdf for Windows or is there an easy solution?
I've followed the instructions until it is said to add C:\MinGW-w64\bin and C:\MinGW-w64\lib\mingw to the PATH variable. But then I don't find further specific instructions to install qpdf, only about how to build qpdf with different other programs. The second side question is: is my assumption correct that after I've build qpdf it is installed? But the real question is: What is the best way to build qpdf? I tried the ./config-mingw32 and ./config-mingw64 commands from the section "Building with MinGW" in my C:\MinGW\msys\1.0\bin\bash.exe but got the error messages ./config-mingw32: No such file or directory and have no idea how to fix this issue.
I'm using Windows 10, R version 3.3.2 Patched (2017-01-07 r71934) -- "Sincere Pumpkin Patch" and RStudio 1.0.136.
You basically do not need to build the file on windows. Please follow three steps below:
Download qpdf for windows from https://sourceforge.net/projects/qpdf/?source=typ_redirect
Extract files in a temp folder
Copy the contents of the bin folder to %SystemRoot%\System32
job done!
Sys.which(Sys.getenv("R_QPDF", "qpdf"))
qpdf
"C:\\WINDOWS\\SYSTEM32\\qpdf.exe"
To flesh out an answer provided elsewhere:
If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage. If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 10.0.1 is listed here).
Rather than copying files to C:/Windows/System32, a potentially safer option is to extracted the zipped qpdf directory to C:\Program Files. If you do this, you'll need to add C:\Program Files\qpdf-version_number\bin to your system PATH under the environment variables.
To do this within R, run Sys.setenv('PATH' = paste0('C:\Program Files\qpdf-version_numer\bin;', Sys.getenv('PATH')))
To do this in Windows, open the start menu, type "edit the system environment variables" to open the System Properties, and at the bottom of the "Advanced" tab click "Environment variables". Find the "Path" entry under "System variables" and click "Edit". Then, re-start R so it picks up the modified PATH.
One further step may be required to convince Windows that pqdf is safe to run.
Navigate to C:\Program Files\qpdf-version_numer\bin and execute qpdf.exe (by double-clicking). Windows 10 throws up a security warning, as it's an unrecognized executable file. You'll need to use the more options link to find the button to run the program. This done, Windows will recognize the file as safe to run and allow other software, including R, to use it.
I'm trying to run R from iTerm on an OSX computer (OSX 10.11.6). When I enter R, it opens up an older version of R, from the path /Users/***/miniconda2/bin/R. I would like it to run, by default, an R version found at /usr/local/bin/R, without having to enter the full path every time. How would one go about changing the location of the default R?
Thanks for your help
This is likely due to the PATH variable preferring ~/miniconda2/bin before /usr/local/bin. I'm giving you a few options here to help understand why it is happening.
Let's assume your PATH looks like this:
/Users/me/bin:/Users/me/miniconda2/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Modify PATH
You could modify PATH to move /Users/me/miniconda2/bin after /usr/local/bin or remove it from PATH completely. The downside is that if you rely on other binaries in ~/miniconda2/bin they will no longer be found when executing them by name.
Move R out of the way
Another option would be to move ~/miniconda/bin/R out of the way, for example using
mv ~/miniconda/bin/R ~/miniconda/bin/R-miniconda
Afterwards R will be run from the next location in $PATH, but if you update miniconda2 it may return.
Link to R further up in the PATH (easiest/best)
Finally, you could make sure that there is an R executable in something that is further up the $PATH. This is probably the easiest and most effective option.
First, make sure you have a bin folder in your home directory. If this is not the case, create it using mkdir ~/bin and then restart the terminal. The restart should cause the code in ~/.profile to add that folder to your $PATH. You can verify by doing echo $PATH. If this is not the case, add the following line to your ~/.profile or ~/.bash_profile:
export PATH=$HOME/bin:$PATH
In the example at the top, the PATH already contains /Users/me/bin at the beginning of the line (highest priority).
Next, create a soft link to the R binary in the newly created folder:
ln -s /usr/local/bin/R ~/bin/R
You should now be able to execute R, which will prefer the softlink created, which will execute the one you like. If it does not work right away execute hash -r or restart the terminal.
Just in case you happen to be using RStudio Server (open source) or someone is looking for how to change the RStudio Server default version of R, here is what I found when trying to answer the same question:
Starting in RStudio Server 1.3 (the newest version is 1.4.1106, released February 22, 2021), a user’s preferred version of R can be specified in the rstudio-prefs.json file in the global-level /etc/rstudio folder or in the user-level ~/.config/rstudio folder.
See https://blog.rstudio.com/2020/02/18/rstudio-1-3-preview-configuration/ and https://docs.rstudio.com/ide/server-pro/session-user-settings.html for user setting options in newer versions of RStudio Server.
See https://support.rstudio.com/hc/en-us/articles/200716783-RStudio-Release-History for RStudio release history and https://www.rstudio.com/products/rstudio/download-server/redhat-centos/ for Red Hat downloads of the newest version of RStudio Server.