Frequently Asked Questions

« Previous
How do snapshots in the HNAS file server work?
Next «
How to get started with SNIC Science Cloud?

130. I have installed R in another location. How do I use it in a script?

If you are running macOS or Ubuntu and have installed R in for example in /opt/local64/R/3.1.1/ and have /opt/local64/R/3.1.1/bin in your path would like to write scripts that use this location, and any other location where you install new versions of R, you may use /bin/env to start R.

The general idea in Unix is that the operating system and the packaging system install software in /bin and /usr/bin. The user install for a local system manually in /usr/local/bin. Shared software over a distributed file system (NFS, Lustre, CepFS..) usually resides in /sw /opt /srv. A packaging system external to the OS (like MacPorts) usually resides in /opt/local.

$ which R
/opt/local64/R/3.1.1/bin/R
$ cat >test.r <<EOF
> #!/bin/env Rscript
>
> print('hello')
>
> EOF
$ cat test.r
#!/bin/env Rscript

print('hello')

$ chmod +x test.r
$ ./test.r
[1] "hello"
$ _

This entry ubuntu.path was last modified 2017-06-22