Skip to main content
Remove incorrect information.
Source Link
Cam_Aust
  • 2.8k
  • 2
  • 23
  • 30

You can choose a different alias name to "Rv340". You can even use "R" and assign it to only this version.

You can choose a different alias name to "Rv340". You can even use "R" and assign it to only this version.

You can choose a different alias name to "Rv340".

Minor edit
Source Link
Cam_Aust
  • 2.8k
  • 2
  • 23
  • 30

I then save (ctrl O, return), then ctrl X to quite nano. Thenthe changes and exit this terminal session.

exit

Then I then open a new Terminal window. (This is so the changes to the env above are incorporated in yourthe new terminal session).

I then save (ctrl O, return), then ctrl X to quite nano. Then exit this terminal session.

exit

Then open a new Terminal window. (This is so the changes to the env above are incorporated in your new terminal session).

I then save the changes and exit this terminal session. I then open a new Terminal window. (This is so the changes to the env above are incorporated in the new terminal session).

Major crafting of answer
Source Link
Cam_Aust
  • 2.8k
  • 2
  • 23
  • 30

An answer for those not that familiar with Terminal and Bash.

I have done a fresh update install of R from the R.org, cran site as part of seeking an answer to your question.

I found this latest install version 3.4.0 installs R for access in Terminal, and also installs R.app as part of the package. 

To my understanding, reading support docs, if you have an older version of R it will update that. However it will not update an installation of R installed by the anaconda package.

 

You ask, where are the R files stored?Where are the R files stored?

I can only assume that with a fresh install of the latest R, R will work for you in Terminal. If not, read further below.

InTo learn where the R files are that are being accessed - in Terminal after starting R, orand in R.app, one can type:

to learn where the R files being accessed are located.

 

In my case:In my case as example:

In R.app - the R accessed is in the top directory: /Library/Frameworks/R.framework/Resources - and is version 3.4.0 is accessed in the top directory (not my user folder):

R.home()
[1] "/Library/Frameworks/R.framework/Resources"

In Terminal - the R accessedversion 3.3.2 is accessed in the Anaconda package, again in the top level directory /anaconda/lib/R - and is version 3.3.2

R.home()
[1] "/anaconda/lib/R"

To ensureSo I use the latest versionhave two different versions of R when invoking R in, and Terminal accesses a different version to R.app.


How can I ensure I access the same version in Terminal as I do in the R.app?

For someone familiar with bash, and how the whole bash command system works I am sure there is a well constructed command. All the same here are some novice solutions.

-

• First Solution:

I could update the anaconda version, however, I would prefer not to as as other elements of the anaconda package my depend on this older version of R. For those not yet familiar with Terminal and bash, not such a novice solution.

So the-

• Second Solution:

This solution iscame from mko. It provides a single use solution. From the result above, and checking the directory structure a little further to havefind this R file.

icon in finder

Finding the significant R file enables me to edit an extension of the above path shown in Terminal find the newerR.app. So add /bin/R to enter

/Library/Frameworks/R.framework/Resources/bin/R

Entering and samepressing return will start R from this version as is run.

Alternatively, one can find this file and icon in the GUI Finder, lead by the above result, and just double click on it, and it will open Terminal and a session with R running for you.app Easy!

One could also make an alias of it and put it on your desktop for easy future starts.

-

• Third Solution:

My last solution I achievedthink may be best, adding to mko's solution. Make an alias.

Being in my home directory in Terminal I open .bash_profile using the nano text editor. (If you do not already know how to do this by doing, then best not use this solution.)

I then add the followingline in this env file.

alias Rv340='/Library/Frameworks/R.framework/Resources/bin/R'

I copiedthen save (ctrl O, return), then ctrl X to quite nano. Then exit this terminal session.

exit

Then open a new Terminal window. (This is so the changes to the env above are incorporated in your new terminal session).

Then when I enter the alias:

Rv340

The version of R I want opens.

You can choose a different alias name to "Rv340". You can even use "R" and assign it to only this version.

-

• Fourth Solution:

A second more permanent solution for opening the same version of R in Terminal is as follows.

Copy the path as showing in R.app in response to the R.home() command above, and addedadd that path to PATH in myyour .bash_profile. (If you do not know already how to do this, then ignore this solution.) Do so as follows.

To my understanding, this ensures that bash looks here for R (and anything else), then moves on to the other paths in PATH. This waySince this adds this path to the beginning of $PATH, when looking for Ran env variable, bash looks here first where it finds the newer version first, and stops looking.

I found the following two links helpfulWhen it comes to understandunderstanding PATH in the env set up in .bash_profile the following two links were helpful.

[About PATH][1]About PATH.

[unix.stackexchange.com Add-a-path-to-path][2]How to correctly add a path to PATH.

This solution may muck with anaconda's invocation of R. II have yet to check this.

Open to other solutions.

I have done a fresh update install of R from the R.org, cran site.

I found this latest install version 3.4.0 installs R for access in Terminal, and also installs R.app as part of the package. To my understanding reading docs, if you have an older version it will update it.

You ask, where are the R files stored?

I can only assume that with a fresh install of the latest, R will work for you in Terminal. If not, read further below.

In Terminal after starting R, or in R.app, one can type:

to learn where the R files being accessed are located.

In my case:

In R.app - the R accessed is in the top directory: /Library/Frameworks/R.framework/Resources - and is version 3.4.0

In Terminal - the R accessed is in the Anaconda package in the top directory /anaconda/lib/R - and is version 3.3.2

To ensure I use the latest version of R when invoking R in Terminal, I could update the anaconda version, however, I would prefer not to as as other elements of the anaconda package my depend on this older version of R.

So the solution is to have R in Terminal find the newer and same version as is run in the R.app. I achieved this by doing the following.

I copied the path as showing in R.app in response to the R.home() command, and added that path to PATH in my .bash_profile as follows.

To my understanding, this ensures that bash looks here for R (and anything else), then moves on to the other paths in PATH. This way, when looking for R, it finds the newer version first, and stops looking.

I found the following two links helpful to understand PATH in the env set up in .bash_profile.

[About PATH][1]

[unix.stackexchange.com Add-a-path-to-path][2]

This solution may muck with anaconda's invocation of R. I have yet to check this.

Open to other solutions.

An answer for those not that familiar with Terminal and Bash.

I have done a fresh update install of R from the R.org cran site as part of seeking an answer to your question.

I found this latest install version 3.4.0 installs R for access in Terminal, and also installs R.app as part of the package. 

To my understanding, reading support docs, if you have an older version of R it will update that. However it will not update an installation of R installed by the anaconda package.

 

Where are the R files stored?

I can only assume that with a fresh install of the latest R, R will work for you in Terminal.

To learn where the R files are that are being accessed - in Terminal after starting R, and in R.app, type:

 

In my case as example:

In R.app - the R version 3.4.0 is accessed in the top directory (not my user folder):

R.home()
[1] "/Library/Frameworks/R.framework/Resources"

In Terminal - the R version 3.3.2 is accessed in the Anaconda package, again in the top level directory.

R.home()
[1] "/anaconda/lib/R"

So I have two different versions of R, and Terminal accesses a different version to R.app.


How can I ensure I access the same version in Terminal as I do in the R.app?

For someone familiar with bash, and how the whole bash command system works I am sure there is a well constructed command. All the same here are some novice solutions.

-

• First Solution:

I could update the anaconda version, however, I would prefer not to as as other elements of the anaconda package my depend on this older version of R. For those not yet familiar with Terminal and bash, not such a novice solution.

-

• Second Solution:

This solution came from mko. It provides a single use solution. From the result above, and checking the directory structure a little further to find this R file.

icon in finder

Finding the significant R file enables me to edit an extension of the above path shown in the R.app. So add /bin/R to enter

/Library/Frameworks/R.framework/Resources/bin/R

Entering and pressing return will start R from this version.

Alternatively, one can find this file and icon in the GUI Finder, lead by the above result, and just double click on it, and it will open Terminal and a session with R running for you. Easy!

One could also make an alias of it and put it on your desktop for easy future starts.

-

• Third Solution:

My last solution I think may be best, adding to mko's solution. Make an alias.

Being in my home directory in Terminal I open .bash_profile using the nano text editor. (If you do not already know how to do this, then best not use this solution.)

I then add the line in this env file.

alias Rv340='/Library/Frameworks/R.framework/Resources/bin/R'

I then save (ctrl O, return), then ctrl X to quite nano. Then exit this terminal session.

exit

Then open a new Terminal window. (This is so the changes to the env above are incorporated in your new terminal session).

Then when I enter the alias:

Rv340

The version of R I want opens.

You can choose a different alias name to "Rv340". You can even use "R" and assign it to only this version.

-

• Fourth Solution:

A second more permanent solution for opening the same version of R in Terminal is as follows.

Copy the path as showing in R.app in response to the R.home() command above, and add that path to PATH in your .bash_profile. (If you do not know already how to do this, then ignore this solution.) Do so as follows.

To my understanding, this ensures that bash looks here for R (and anything else), then moves on to the other paths in PATH. Since this adds this path to the beginning of $PATH, an env variable, bash looks here first where it finds the newer version first, and stops looking.

When it comes to understanding PATH in the env set up in .bash_profile the following two links were helpful.

About PATH.

How to correctly add a path to PATH.

This solution may muck with anaconda's invocation of R. I have yet to check this.

added 105 characters in body
Source Link
Cam_Aust
  • 2.8k
  • 2
  • 23
  • 30
Loading
Source Link
Cam_Aust
  • 2.8k
  • 2
  • 23
  • 30
Loading