Like in Visual Studio you can group several functions and data they operate in the project, which is a folder in filesystem with a several special files.  When project is opened those special files are loaded automatically creating environment that is close to the one you used to have when you last close the project.

RStudio projects are associated with R working directories. You can create an RStudio project:

To create a new project use the Create Project command (available on the Projects menu and on the global toolbar):

When a new project is created RStudio:
  1. Creates a project file (with the extension.Rproj ) in the project directory. This file contains various project options and can also be used as a shortcut for opening the project directly from the filesystem.
  2. Creates a hidden directory (named .Rproj.user ) where project-specific temporary files (e.g. auto-saved source documents, window-state, etc.) are stored. This directory is also automatically added to .Rbuildignore, .gitignore, etc. if required.
  3. Loads the project into RStudio and display its name in the Projects toolbar (which is located on the far right side of the main toolbar)

There are several ways to open a project:

  1. Using the Open Project command (available from both the Projects menu and the Projects toolbar) to browse for and select an existing project file (e.g. MyProject.Rproj).
  2. Selecting a project from the list of most recently opened projects (also available from both the Projects menu and toolbar).
  3. Double-clicking on the project file within the system shell (e.g. Windows Explorer, OSX Finder, etc.).

When a project is opened within RStudio the following actions are taken:

To run a script pass a string with its name to the source function.

When you are within a project and choose to either Quit, close the project, or open another project the following actions are taken:

You can work with more than one RStudio project at a time by simply opening each project in its own instance of RStudio. There are two ways to accomplish this:

  1. Use the Open Project in New Window command located on the Project menu.
  2. Opening multiple project files via the system shell (i.e. double-clicking on the project file).

There are several options that can be set on a per-project basis to customize the behavior of RStudio. You can edit these options using the Project Options command on the Project menu:

R command line provides access to help via ?[function] or ??[topic]

Sites and free books 

Note: An excellent resource as books and websites related to R is 60+ R resources to improve your data skills Computerworld. Please visit it.

A large, cookbook-style collection of material on R contains Stack Overflow site.

Free books (adapted from The R Programming Language - Free Computer, Programming, Mathematics, Technical Books, Lecture Notes and Tutorials)

R has its own LaTeX-like documentation format, which is used to supply comprehensive documentation, both on-line in a number of formats and in hard copy.

See also R Bookshelf

Packages and CRAN

The power of R is heavily based on a large set available packages which extend the core language. R package structure reminds Perl. Similar to Perl, the main repository is called Comprehensive R Archive Network (CRAN). It contains thousands of packages. A core set of packages is included with the installation of R The set of packages loaded on startup is by default can be displayed using the command:

> getOption("defaultPackages")

All-in-all there are around 6K additional packages for R and 120,000 functions (as of June 2014) available at the CRAN and other repositories.  In other words R like Perl is suffering from package glut.  the following discussion would resonate with any long-term Perl user (Does R have too many packages R-bloggers)

1 Lack of long term maintenance of packages.  This has been a challenge that I have faced when using R packages which I believe will provide the solution to my problem but these packages frequently are not maintained at the same rate as the R base system.

And how could they be?  The base system is updated several times a year while there are thousands of packages.  To update each of those packages for minor changes in the base system seems foolish and excessive.  However, as the current structure of R stands, to fail to update these packages results in packages which previously worked, no longer functioning.  This is a problem I have experienced and is frankly very annoying.

One solution might be to limit the number of packages to those which have a sufficient developer base to ensure long term maintenance.  However, this would likely stifle the creativity and productivity of the wide R developer base.

Another solution is to limit the number of base system updates in order to limit the likelihood that a package will become outdated and need updating.

A third option, which I believe is the most attractive, is to allow code to specify what version of R it is stable on and for R to act for the commands in that package as though it is running on a previous version of R.  This idea is inspired by how Stata handles user written commands.  These commands simply specify version number for which the command was written under.  No matter what later version of Stata is used, the command should still work.

I understand that such an implementation would require additional work from the R core team for each subsequent update.  However, such an investment may be worth it in the long run as it would decrease the maintenance in response to R base updates.

2 The super abundance of R packages.  The concern is that there are so many packages that users might find it difficult to wade through them in order to find the right package.  I don't really see this as a problem.  If someone wanted to learn to use all R packages then of course this task would be nearly impossible.  However, with me as I believe with most people, I learn to use new functions within packages to solve specific problems.  I don't really care how many packages there are out there.  All I care is that when I ask a question on google or StackOverflow about how to do x or y, someone can point me to the package and command combination necessary to accomplish the task.

3 The inconsistent quality of individual packages.  It is not always clear if user written packages are really doing what they claim to be doing.  I know personally I and am constantly on the look out for checks to make sure my code is doing what I think it is doing, yet still I consistently find myself making small errors which only show up through painstaking experimentation and debugging. 

CRAN has some automated procedures in which packages are tested to ensure that all of their functions work without errors under normal circumstances.  However, as far as I know, there are no automated tests to ensure the commands are not silently giving errors by doing the wrong thing.  These kind of error controls are entirely left up to the authors and users.  This concern comes to mind because one of my friends recently was running two different Bayesian estimation packages which were supposed to produce identical results yet each returned distinctly different results with one set having significant estimates and the other not.  If he had not thought to try two different packages then he would never have thought of the potential errors inherent in the package authorship.

A solution to inconsistent package quality controls may be to have a multitiered package release structure in which packages are first released in "beta form" but require an independent reviewing group to check functionality and write up reports before attaining "full" release status.  Such an independent package review structure may be accomplished by developing an open access R-journal specifically geared towards the review, release, and revision of R packages.

4 The lack of hierarchical dependencies.  This is a major point mentioned in Kurt Hornik's paper.  He looks at package dependencies and found that the majority of packages have no dependencies upon other packages.  This indicates that while there are many packages out there, most packages are not building on the work of other packages.  This produces the unfortunate situation in which it seems that many package developers are recreating the work of other package developers.  I am not really sure if there is anything that can be done about this or if it really is an issue.

It does not bother me that many users recode similar or duplicate code because I think the coding of such code helps the user better understand the R system, the user's problem, and the user's solution.  There is however the issue that the more times a problem is coded, the more likely someone will code an error.  This beings us back to point 3 in which errors must be rigorously pursued and ruthlessly exterminated through use of an independent error detection system.

5 Insufficient Meta Package AnalysisA point that Kurt Hornik also raises is that there are a lot of R packages out there but not a lot of information about how those packages are being used.  In order to further this goal, it might be useful to build into future releases of R the option to report usage statistics on which packages and functions are being used in combination with which other packages.  Package developers might find such information useful when evaluating what functions to update.

R packages are installed into libraries, which are directories in the file system containing a subdirectory for each package installed there.

R comes with a single library, R_HOME/library which is the value of the R object ‘.Library’ containing the standard and recommended packages.

Both sites and users can create others and make use of them (or not) in an R session. At the lowest level ‘.libPaths()’ can be used to add paths to the collection of libraries or to report the current collection.

R will automatically make use of a site-specific library R_HOME/site-library if this exists (it does not in a vanilla R installation). This location can be overridden by setting ‘.Library.site’ in R_HOME/etc/Rprofile.site, or (not recommended) by setting the environment variable R_LIBS_SITE. Like ‘.Library’, the site libraries are always included into ‘.libPaths()’.

Users can have one or more libraries, normally specified by the environment variable R_LIBS_USER. This has a default value (to see it, use ‘Sys.getenv("R_LIBS_USER")’ within an R session), but that is only used if the corresponding directory actually exists (which by default it will not).

Both R_LIBS_USER and R_LIBS_SITE can specify multiple library paths, separated by colons (semicolons on Windows).

Another strength of R is static graphic which can be produced using ggplot2 package. It can produce publication-quality graphs, including mathematical symbols. Dynamic and interactive graphics are available through additional packages.

Packages allow specialized statistical techniques, graphic output (ggplot2), import/export capabilities, reporting tools (knitr, Sweave), etc. Packages are developed primarily in R. Sometimes C, C++,  Fortran are used. 

Other R package repositories include  R-forge and Bioconductor

There is also a community site for rating and reviewing all CRAN packages called Crantastic.

Language

Adapted from Programming in R Thomas Girke, UC Riverside

R is C style language that does not do a good job of enhancing C syntax and avoiding it shortcomings. It is stuck in 90 mentality and in comparison with Perl does not extend syntax much.

This is the dynamically typed language with fist class functions, closures, objects, vector operations, pass parameters by value. Has special values for variables such as NULL and NA. Everything is nullable.

R is an interpreted language; users typically access it through a command-line interpreter. If a user types "2+2" at the R command prompt and presses Enter, the computer replies with "4", as shown below:

> 2+2 
[1] 4

Variable names in R can contain dot character which serves the role similar to underscore (... is used to indicate a variable number of function arguments). R uses $ in a manner analogous to the way other languages use dot.

R has several one-letter reserved words: c, q, s, t, C, D, F, I, and T.

R's data structures include vectors, lists, matrices, arrays, data frames (list of vectors; similar to tables in a relational database). There is no scalar type in R. A scalar is represented as a vector with length one  The scalar data type was never a data structure of R. 

Vectors are one dimensional collections used to, most frequently, store one sort of data (Numbers, Text, ...).  Indices in R start at 1, not at 0. In this way R resembles FORTRAN.  x[1] is the first element of vector x. Vector is  an ordered collection of elements with no other structure. The length of a vector is the number of elements. Operations are applied componentwise. For example, given two vectors x and y of equal length, x*y would be the vector whose nth component is the product of the nth components of x and y. Also, log(x) would be the vector whose nth component is the logarithm of the nth component of x. Vectors are created using the c function. For example, p <- c(2,3,5,7) sets p to the vector containing the first four prime numbers.

R supports procedural programming with functions. A generic function acts differently depending on the type of arguments passed to it. In other words, the generic function dispatches the function (method) specific to that type of object. There is also OO system for R (actually two). 

R has a generic print() function that can print almost every type of object in R with a simple

print(objectname)

Overview of syntax.

Statistical features

R and its libraries implement a wide variety of statistical and graphical techniques, including linear and nonlinear modeling, classical statistical tests, time-series analysis, classification, clustering, and others. R is easily extensible through functions and extensions, and the R community is noted for its active contributions in terms of packages. There are some important differences, but much code written for S runs unaltered. Many of R's standard functions are written in R itself, which makes it easy for users to follow the algorithmic choices made.

R can link and call at run time C, C++, and Fortran code. Advanced users can write their own C, C++, Java, [NET or Python code to manipulate R objects directly.

Examples

Readers wishing to get a feel for R can start with the introductory session given in A sample session.

From Wikipedia:

Example 1[edit]

The following examples illustrate the basic syntax of the language and use of the command-line interface.

In R, the widely preferred assignment operator is an arrow made from two characters "<-", although "=" can be used instead.[26]

> x <- c(1,2,3,4,5,6) # Create ordered collection (vector)
> y <- x^2 # Square the elements of x
> print(y) # print (vector) y
[1] 1 4 9 16 25 36
> mean(y) # Calculate average (arithmetic mean) of (vector) y; result is scalar
[1] 15.16667
> var(y) # Calculate sample variance
[1] 178.9667
> lm_1 <- lm(y ~ x) # Fit a linear regression model "y = f(x)" or "y = B0 + (B1 * x)"
# store the results as lm_1
> print(lm_1) # Print the model from the (linear model object) lm_1

Call:

lm(formula = y ~ x)

Coefficients:

(Intercept) x
-9.333 7.000

> summary(lm_1) # Compute and print statistics for the fit # of the (linear model object) lm_1

Call:
lm(formula = y ~ x)
Residuals:
1 2 3 4 5 6
3.3333 -0.6667 -2.6667 -2.6667 -0.6667 3.3333
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -9.3333 2.8441 -3.282 0.030453 *
x 7.0000 0.7303 9.585 0.000662 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.055 on 4 degrees of freedom
Multiple R-squared: 0.9583, Adjusted R-squared: 0.9478
F-statistic: 91.88 on 1 and 4 DF, p-value: 0.000662
> par(mfrow=c(2, 2)) # Request 2x2 plot layout
> plot(lm_1) # Diagnostic plot of regression model

Diagnostic graphs produced by plot.lm() function. Features include mathematical notation in axis labels, as at lower left.

Example 2[edit]

Short R code calculating Mandelbrot set through the first 20 iterations of equation z = z² + c plotted for different complex constants c. This example demonstrates: use of community-developed external libraries (called packages), in this case caTools package handling of complex numbers multidimensional arrays of numbers used as basic data type, see variables C, Z and X.

library(caTools) # external package providing write.gif function
jet.colors <- colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F",
"yellow", "#FF7F00", "red", "#7F0000"))
m <- 10000 # define size
C <- complex( real=rep(seq(-1.8,0.6, length.out=m), each=m ),
imag=rep(seq(-1.2,1.2, length.out=m), m ) )
C <- matrix(C,m,m) # reshape as square matrix of complex numbers
Z <- 0 # initialize Z to zero
X <- array(0, c(m,m,20)) # initialize output 3D array
for (k in 1:20) { # loop with 20 iterations
Z <- Z^2+C # the central difference equation
X[,,k] <- exp(-abs(Z)) # capture results
}
write.gif(X, "Mandelbrot.gif", col=jet.colors, delay=800)

"Mandelbrot.gif" – Graphics created in R with 14 lines of code in Example 2

Example 3[edit]

The ease of function creation by the user is one of the strengths of using R. Objects remain local to the function, which can be returned as any data type.[27] Below is an example of the structure of a function:

functionname <- function(arg1, arg2, ... ){ # declare name of function and function arguments
statements # declare statements
return(object) # declare object data type
}
sumofsquares <- function(x){ # a user-created function 
return(sum(x^2)) # return the sum of squares of the elements of vector x
}
> sumofsquares(1:3)
[1] 14

Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Oct 20, 2019] Using command line arguments to R CMD BATCH

Oct 20, 2019 | stackoverflow.com

Ask Question Asked 6 years, 9 months ago Active 1 year, 7 months ago Viewed 112k times 93 54


Bryce Thomas ,Jan 5, 2013 at 0:26

I have been using R CMD BATCH my_script.R from a terminal to execute an R script. I am now at the point where I would like to pass an argument to the command, but am having some issues getting it working. If I do R CMD BATCH my_script.R blabla then blabla becomes the output file, rather than being interpreted as an argument available to the R script being executed.

I have tried Rscript my_script.R blabla which seems to pass on blabla correctly as an argument, but then I don't get the my_script.Rout output file that I get with R CMD BATCH (I want the .Rout file). While I could redirect the output of a call to Rscript to a file name of my choosing, I would not be getting the R input commands included in the file in the way R CMD BATCH does in the .Rout file.

So, ideally, I'm after a way to pass arguments to an R script being executed via the R CMD BATCH method, though would be happy with an approach using Rscript if there is a way to make it produce a comparable .Rout file.

Bryce Thomas ,Feb 11, 2015 at 20:59

My impression is that R CMD BATCH is a bit of a relict. In any case, the more recent Rscript executable (available on all platforms), together with commandArgs() makes processing command line arguments pretty easy.

As an example, here is a little script -- call it "myScript.R" :

## myScript.R
args <- commandArgs(trailingOnly = TRUE)
rnorm(n=as.numeric(args[1]), mean=as.numeric(args[2]))

And here is what invoking it from the command line looks like

> Rscript myScript.R 5 100
[1]  98.46435 100.04626  99.44937  98.52910 100.78853

Edit:

Not that I'd recommend it, but ... using a combination of source() and sink() , you could get Rscript to produce an .Rout file like that produced by R CMD BATCH . One way would be to create a little R script -- call it RscriptEcho.R -- which you call directly with Rscript. It might look like this:

## RscriptEcho.R
args <- commandArgs(TRUE)
srcFile <- args[1]
outFile <- paste0(make.names(date()), ".Rout")
args <- args[-1]

sink(outFile, split = TRUE)
source(srcFile, echo = TRUE)

To execute your actual script, you would then do:

Rscript RscriptEcho.R myScript.R 5 100
[1]  98.46435 100.04626  99.44937  98.52910 100.78853

which will execute myScript.R with the supplied arguments and sink interleaved input, output, and messages to a uniquely named .Rout .

Edit2:
You can run Rscript verbosely and place the verbose output in a file.

Rscript --verbose myScript.R 5 100 > myScript.Rout

d2a2d ,Apr 9 at 22:33

After trying the options described here, I found this post from Forester in r-bloggers . I think it is a clean option to consider.

I put his code here:

From command line

$ R CMD BATCH --no-save --no-restore '--args a=1 b=c(2,5,6)' test.R test.out &

Test.R

##First read in the arguments listed at the command line
args=(commandArgs(TRUE))

##args is now a list of character vectors
## First check to see if arguments are passed.
## Then cycle through each element of the list and evaluate the expressions.
if(length(args)==0){
    print("No arguments supplied.")
    ##supply default values
    a = 1
    b = c(1,1,1)
}else{
    for(i in 1:length(args)){
      eval(parse(text=args[[i]]))
    }
}

print(a*2)
print(b*3)

In test.out

> print(a*2)
[1] 2
> print(b*3)
[1]  6 15 18

Thanks to Forester !

user1563570 ,Apr 5, 2013 at 13:15

In your R script, called test.R :
args <- commandArgs(trailingOnly = F)
myargument <- args[length(args)]
myargument <- sub("-","",myargument)
print(myargument)
q(save="no")

From the command line run:

R CMD BATCH -4 test.R

Your output file, test.Rout, will show that the argument 4 has been successfully passed to R:

cat test.Rout

> args <- commandArgs(trailingOnly = F)
> myargument <- args[length(args)]
> myargument <- sub("-","",myargument)
> print(myargument)
[1] "4"
> q(save="no")
> proc.time()
user  system elapsed 
0.222   0.022   0.236

Bryce Thomas ,Oct 23, 2014 at 20:57

You need to put arguments before my_script.R and use - on the arguments, e.g.
R CMD BATCH -blabla my_script.R

commandArgs() will receive -blabla as a character string in this case. See the help for details:

$ R CMD BATCH --help
Usage: R CMD BATCH [options] infile [outfile]

Run R non-interactively with input from infile and place output (stdout
and stderr) to another file.  If not given, the name of the output file
is the one of the input file, with a possible '.R' extension stripped,
and '.Rout' appended.

Options:
  -h, --help        print short help message and exit
  -v, --version     print version info and exit
  --no-timing           do not report the timings
  --            end processing of options

Further arguments starting with a '-' are considered as options as long
as '--' was not encountered, and are passed on to the R process, which
by default is started with '--restore --save --no-readline'.
See also help('BATCH') inside R.

ClementWalter ,Mar 16, 2016 at 9:52

I add an answer because I think a one line solution is always good! Atop of your myRscript.R file, add the following line:
eval(parse(text=paste(commandArgs(trailingOnly = TRUE), collapse=";")))

Then submit your script with something like:

R CMD BATCH [options] '--args arguments you want to supply' myRscript.R &

For example:

R CMD BATCH --vanilla '--args N=1 l=list(a=2, b="test") name="aname"' myscript.R &

Then:

> ls()
[1] "N"    "l"    "name"

Dagremu ,Dec 15, 2016 at 0:50

Here's another way to process command line args, using R CMD BATCH . My approach, which builds on an earlier answer here , lets you specify arguments at the command line and, in your R script, give some or all of them default values.

Here's an R file, which I name test.R :

defaults <- list(a=1, b=c(1,1,1)) ## default values of any arguments we might pass

## parse each command arg, loading it into global environment
for (arg in commandArgs(TRUE))
  eval(parse(text=arg))

## if any variable named in defaults doesn't exist, then create it
## with value from defaults
for (nm in names(defaults))
  assign(nm, mget(nm, ifnotfound=list(defaults[[nm]]))[[1]])

print(a)
print(b)

At the command line, if I type

R CMD BATCH --no-save --no-restore '--args a=2 b=c(2,5,6)' test.R

then within R we'll have a = 2 and b = c(2,5,6) . But I could, say, omit b , and add in another argument c :

R CMD BATCH --no-save --no-restore '--args a=2 c="hello"' test.R

Then in R we'll have a = 2 , b = c(1,1,1) (the default), and c = "hello" .

Finally, for convenience we can wrap the R code in a function, as long as we're careful about the environment:

## defaults should be either NULL or a named list
parseCommandArgs <- function(defaults=NULL, envir=globalenv()) {
  for (arg in commandArgs(TRUE))
    eval(parse(text=arg), envir=envir)

  for (nm in names(defaults))
    assign(nm, mget(nm, ifnotfound=list(defaults[[nm]]), envir=envir)[[1]], pos=envir)
}

## example usage:
parseCommandArgs(list(a=1, b=c(1,1,1)))

[Oct 20, 2019] How can I use multiple library paths?

Oct 20, 2019 | stackoverflow.com

Ask Question Asked 2 years, 10 months ago Active 2 years, 10 months ago Viewed 747 times 2 0

user797963 ,Nov 28, 2016 at 16:11

I'm trying to set up an easy to use R development environment for multiple users. R is installed along with a set of other dev tools on an NFS mount.

I want to create a core set of R packages that also live on NFS so n users don't need to install their own copies of the same packages n times. Then, I was hoping users can install one off packages to a local R library. Has anyone worked with an R setup like this before? From the doc, it looks doable by adding both the core package and personal package file paths to .libPaths() .

,

You want to use the .Renviron file (see ?Startup ).

There are three places to put the file:

  • Site wide in R_HOME/etc/Renviron.site
  • Local in either the current working directory or the home area

In this file you can specify R_LIBS and the R_LIBS_SITE environment variables.

For your particular problem, you probably want to add the NFS drive location to R_LIBS_SITE in the R_HOME/etc/Renviron.site file.


## To get R_HOME
Sys.getenv("R_HOME")

[Oct 20, 2019] How to update a package in R?

Oct 20, 2019 | stackoverflow.com

Ask Question Asked 5 years, 8 months ago Active 10 months ago Viewed 23k times 23 4


Joshua Ulrich ,Jan 31, 2014 at 8:15

I would like to upgrade one R package to the newer version which is already available. I tried
update.packages(c("R2jags"))

but it does nothing! No output on console, no error, nothing. I used the same syntax as for install.packages but perhaps I'm doing something wrong. I have been looking at ?update.packages but I was not been able to figure out how it works, where to specify the package(s) etc. There is no example. I also tried to update the package using install.packages to "install" it again but that says "Warning: package 'R2jags' is in use and will not be installed" .

TMS ,Jan 30, 2014 at 16:47

You can't do this I'm afraid, well, not with update.packages() . You need to call install.packages("R2jags") instead.

You can't install R2jags in the current session because you have already loaded the current version into the session. If you need to, save any objects you can't easily recreate, and quit out of R. Then start a new R session, immediately run install.packages("R2jags") , then once finished, load the package and reload in any previously saved objects. You could try to unload the package with:

detach(package:R2jags, unload = TRUE)

but it is quite complex to do this cleanly unless the package cleans up after itself.

update.packages() exists to update all outdated packages in a stated library location. That library location is given by the first argument (if not supplied it works on all known library locations for the current R session). Hence you were asking it the update the packages in library location R2jags which is most unlikely to exist on your R installation.

amzu ,Jan 30, 2014 at 16:36

Additionally, you can install RStudio and update all packages by going to the Tools menu and selecting Check for Package Updates .

DJ6968 ,Dec 13, 2018 at 11:42

# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }

# Next, we download packages that H2O depends on.
pkgs <- c("RCurl","jsonlite")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}

# Now we download, install and initialize the H2O package for R.
install.packages("h2o", type="source", repos="http://h2o-release.s3.amazonaws.com/h2o/rel-xia/2/R")

# Finally, let's load H2O and start up an H2O cluster
library(h2o)`enter code here`
h2o.init()

[Oct 16, 2019] Help regarding package installation: .Renviron, .Rprofile, R_LIBS, R_LIBS_SITE, and R_LIBS_USER Oh my!

Sep 07, 2018 | community.rstudio.com

jimhester RStudio Employee 2018-09-07 From the help for ?.libPaths

By default R_LIBS is unset, and R_LIBS_USER is set to
subdirectory R/win-library/x.y of the home directory,
for R x.y.z .

However the directories are only included in your library path if they exist (which they will not by default).

So I would recommend you create the directory for each minor version of R, e.g. dir.create("~/R/win-library/3.5") and install packages there. The base and recommended packages will be installed with R.

You will only need to install new packages when the minor version changes; e.g. when R 3.6.0 is released. For patch versions of R you can use the same library.

Using this approach means you don't have to worry about setting any of the environment variables yourself or dealing with any of the R startup files. Gerg 2018-09-07

jimhester:

So I would recommend you create the directory for each minor version of R, e.g. dir.create("~/R/win-library/3.5") and install packages there. The base and recommended packages will be installed with R.

Thanks! This method works in relation to my windows home directory, but is there a way to set the minor version folders one level further from home e.g.:

"~/software/R/win-library/3.5"
instead of
"~/R/win-library/3.5" nwerth Sustainer 2018-09-07 From what I've gathered (which may be totally wrong):

  • R_LIBS_USER
    • Intended to list libraries for a user, which doesn't affect other users.
    • Environment variable which is read at start-up.
    • This would work for you.
  • R_LIBS_SITE
    • Intended to list libraries shared by multiple users at a site (e.g., the same computer).
    • Environment variable which is read at start-up.
    • Good if there's an admin who takes care of installs and upgrades, but not for your situation.
  • .libPaths()
    • Shows libraries in the search path or adds them.
    • Executed in an R session.
    • This would also work for you.
  • R_LIBS :
    • Environment variable which is read at start-up.
    • I have no idea of the intent behind this one.

If you'd like to use R_LIBS_USER , add an .Renviron file to your home directory that has this line:

R_LIBS_USER=c:/users/USER/software/r/libraries/3.5

If you'd like to use .libPaths() instead, add an .Rprofile file to your home directory that has this line:

.libPaths("c:/users/USER/software/r/libraries/3.5")

Either of those should work for as long as the relevant file is in your home directory.

Gerg 1 2018-09-07 Thanks for all the help everyone!

It seems that the R_HOME directory is different from the windows HOME directory. Using the FAQ Q2.14 13 I decided to create an R_USER environment variable in my system settings located in the windows control panel:

Control Panel > System and Security > System > Advanced System settings > Environment Variables
I set the R_USER = C:\Users\Greg\Software

When I closed and reopened r and installed packages they were installed to:
C:\Users\Greg\Software\R\win-library\3.5

The output from .libPaths() is
[1] "C:/Users/Greg/Software/R/win-library/3.5" "C:/Program Files/R/R-3.5.1/library"

This is exactly what I wanted. If you recognize anything wrong with this approach please let me know, otherwise I hope this helps others who ran into this problem on windows! HenrikBengtsson 2018-09-15 For these things, I use (which works on all platforms and after upgrading R):

  1. Set R_LIBS_USER in your ~/.Renviron . One <name>=<value> per line.
  2. Don't hardcode the R version or architecture. Instead make use of so-called "specifiers", which include %p (expands to the architecture, e.g. x86_64-pc-linux-gnu ) and %v (expands to major and minor R version, e.g. 3.5 ) - see ?R_LIBS_USER . Using R_LIBS_USER=~/R/%p-library/%v corresponds to the default R settings.

To know the location of ~/.Renviron , which is not always obvious on Windows, use normalizePath() , e.g.

 > normalizePath("~/.Renviron", mustWork = FALSE)
[1] "/home/hb/.Renviron"

That's on my Linux machine. On your Windows, I think you'll get something like:

 > normalizePath("~/.Renviron", mustWork = FALSE)
 [1] "C:/users/Greg/documents/.Renviron"

Now, if you edit/create that ~/.Renviron file to have a line:

R_LIBS_USER="C:/Users/Greg/Software/R/%p-library/%v

you will get:

> Sys.getenv('R_LIBS_USER')
[1] "C:/Users/Greg/Software/R/win-library/3.5"

and on R 3.6.0 devel, you'll get:

> Sys.getenv('R_LIBS_USER')
[1] "C:/Users/Greg/Software/R/win-library/3.6"

Importantly , if this folder does not exist, then R will silently ignore it, despite properly parsing and expanding R_LIBS_USER , e.g.

> Sys.getenv('R_LIBS_USER')
[1] "C:/Users/Greg/Software/R/win-library/3.5"
> dir.exists(Sys.getenv('R_LIBS_USER'))
[1] FALSE

and .libPaths()[1] will be incorrect. So, you need to create this folder once, e.g.

> Sys.getenv('R_LIBS_USER')
[1] "C:/Users/Greg/Software/R/win-library/3.5"
> dir.create(Sys.getenv('R_LIBS_USER'), recursive = TRUE)
> dir.exists(Sys.getenv('R_LIBS_USER'))
[1] TRUE

Then restart R, and you'll get:

> .libPaths()[1]
[1] "C:/Users/Greg/Software/R/win-library/3.5"
cderv Sustainer 2018-09-15 HenrikBengtsson:

To know the location of ~/.Renviron , which is not always obvious on Windows

usethis::edit_r_environ() is very useful for this! It will open in your editor the file. Gerg 2018-09-17 HenrikBengtsson:

For these things, I use (which works on all platforms and after upgrading R):

  1. Set R_LIBS_USER in your ~/.Renviron . One <name>=<value> per line.
  2. Don't hardcode the R version or architecture. Instead make use of so-called "specifiers", which include %p (expands to the architecture, e.g. x86_64-pc-linux-gnu ) and %v (expands to major and minor R version, e.g. 3.5 ) - see ?R_LIBS_USER . Using R_LIBS_USER=~/R/%p-library/%v corresponds to the default R settings.

To know the location of ~/.Renviron , which is not always obvious on Windows, use normalizePath() , e.g.

[Oct 16, 2019] R libraries installation - Stack Overflow

Oct 31, 2016 | stackoverflow.com

R libraries installation Ask Question Asked 2 years, 11 months ago Active 2 years, 10 months ago Viewed 783 times 0

horseshoe ,Oct 31, 2016 at 14:47

I am using a computer where I have read only rights for the R library folder. When I am installing new packages I therefore use
libpath <- "c:/R/mylibraries"
.libPaths( c( .libPaths(), libpath) )
install.packages("htmltools",   lib=libpath)

always when I am installing a new packages with dependecies (like e.g. htmltools depends on lme4), I get erros like:

Error in .requirePackage(package) : 
  unable to find required package 'lme4'

although lme4 is installed and I used it before.... also other errors/warnings like:

Warning in install.packages :
  cannot remove prior installation of package 'Rcpp'

or:

Warning in install.packages :
  unable to move temporary installation 'c:\...\file17b033a54a21\jsonlite' to 'c:\...\jsonlite'

occur. If I install them twice they usually work but sometimes dependencies to packages that worked before are lost and I have to reinstall them again. Is there a way to circumvent this?

> ,

Put this in a file named .REnviron in your Documents folder and restart R:
R_LIBS=c:/R/mylibraries

From then on, you should be able to install packages into that location automatically, without having to fiddle around with .libPaths .

[Oct 16, 2019] R libraries installation - Stack Overflow

Oct 16, 2019 | stackoverflow.com

R libraries installation Ask Question Asked 2 years, 11 months ago Active 2 years, 10 months ago Viewed 783 times 0

horseshoe ,Oct 31, 2016 at 14:47

I am using a computer where I have read only rights for the R library folder. When I am installing new packages I therefore use
libpath <- "c:/R/mylibraries"
.libPaths( c( .libPaths(), libpath) )
install.packages("htmltools",   lib=libpath)

always when I am installing a new packages with dependecies (like e.g. htmltools depends on lme4), I get erros like:

Error in .requirePackage(package) : 
  unable to find required package 'lme4'

although lme4 is installed and I used it before.... also other errors/warnings like:

Warning in install.packages :
  cannot remove prior installation of package 'Rcpp'

or:

Warning in install.packages :
  unable to move temporary installation 'c:\...\file17b033a54a21\jsonlite' to 'c:\...\jsonlite'

occur. If I install them twice they usually work but sometimes dependencies to packages that worked before are lost and I have to reinstall them again. Is there a way to circumvent this?

> ,

Put this in a file named .REnviron in your Documents folder and restart R:
R_LIBS=c:/R/mylibraries

From then on, you should be able to install packages into that location automatically, without having to fiddle around with .libPaths .

[Oct 16, 2019] R setting library path via R_LIBS

Oct 16, 2019 | stackoverflow.com

Ask Question Asked 3 years, 4 months ago Active 3 years, 1 month ago Viewed 5k times 2

Xiongbing Jin ,Jun 12, 2016 at 12:42

I have read the R FAQS and other posts but I am a bit confused and would be grateful to know whether I did everything correctly.

In Windows, in order to modify the default library folder I created a file Renviron.site and put inside E:/Programs/R-3.3.0/etc . The file has only one line saying

R_LIBS=E:/Rlibrary

When I open R and run .libPaths() I see E:/Rlibrary as [1] and the default R library E:/Programs/R-3.3.0/library as [2].

This should mean that from now on all packages I will install will go in E:/Rlibrary but at the same time I will be able to load and use both packages in this folder and those in the default location. Am I correct?

,

When you load a package via library , it will go through each directory in .libPaths() in turn to find the required package. If the package hasn't been found, you will get an error. This means you can have multiple versions of a package (in different directories), but the package that will be used is determined by the order of .libPaths() .

Regarding how .libPaths() is constructed, from ?.R_LIBS

The library search path is initialized at startup from the environment variable 'R_LIBS' (which should be a colon-separated list of directories at which R library trees are rooted) followed by those in environment variable 'R_LIBS_USER'. Only directories which exist at the time will be included.

[Oct 16, 2019] The .Rprofile file

Oct 16, 2019 | csgillespie.github.io

3.3 R startup

Every time R starts, a number of files are read, in a particular order. The contents of these files determine how R performs for the duration of the session. Note that these files should only be changed with caution, as they may make your R version behave differently to other R installations. This could reduce the reproducibility of your code.

Files in three folders are important in this process:

  • R_HOME , the directory in which R is installed . The etc sub-directory can contain start-up files read early on in the start-up process. Find out where your R_HOME is with the R.home() command.
  • HOME , the user's home directory . Typically this is /home/username on Unix machines or C:\Users\username on Windows (since Windows 7). Ask R where your home directory with, path.expand("~") (note the use of the Unix-like tilde to represent the home directory).
  • R's current working directory . This is reported by getwd() .

It is important to know the location of the .Rprofile and .Renviron set-up files that are being used out of these three options. R only uses one .Rprofile and one .Renviron in any session: if you have a .Rprofile file in your current project, R will ignore .Rprofile in R_HOME and HOME . Likewise, .Rprofile in HOME overrides .Rprofile in R_HOME . The same applies to .Renviron : you should remember that adding project specific environment variables with .Renviron will de-activate other .Renviron files.

To create a project-specific start-up script, simply create a .Rprofile file in the project's root directory and start adding R code, e.g. via file.edit(".Rprofile") . Remember that this will make .Rprofile in the home directory be ignored. The following commands will open your .Rprofile from within an R editor:

file.edit(file.path("~", ".Rprofile")) # edit .Rprofile in HOME
file.edit(".Rprofile") # edit project specific .Rprofile

Note that editing the .Renviron file in the same locations will have the same effect. The following code will create a user specific .Renviron file (where API keys and other cross-project environment variables can be stored), without overwriting any existing file.

user_renviron = path.expand(file.path("~", ".Renviron"))
if(!file.exists(user_renviron)) # check to see if the file already exists
  file.create(user_renviron)
file.edit(user_renviron) # open with another text editor if this fails

The location, contents and uses of each is outlined in more detail below. 3.3.1 The .Rprofile file

By default R looks for and runs .Rprofile files in the three locations described above, in a specific order. .Rprofile files are simply R scripts that run each time R runs and they can be found within R_HOME , HOME and the project's home directory, found with getwd() . To check if you have a site-wide .Rprofile , which will run for all users on start-up, run:

site_path = R.home(component = "home")
fname = file.path(site_path, "etc", "Rprofile.site")
file.exists(fname)

The above code checks for the presence of Rprofile.site in that directory. As outlined above, the .Rprofile located in your home directory is user-specific. Again, we can test whether this file exists using

file.exists("~/.Rprofile")

We can use R to create and edit .Rprofile (warning: do not overwrite your previous .Rprofile - we suggest you try project-specific .Rprofile first):

if(!file.exists("~/.Rprofile")) # only create if not already there
  file.create("~/.Rprofile")    # (don't overwrite it)
file.edit("~/.Rprofile")
3.3.2 Example .Rprofile settings

An .Rprofile file is just an R script that is run at start-up. The examples at the bottom of the .Rprofile help file

help("Rprofile")

give clues as to the types of things we could place in our profile.

3.3.2.1 Setting options

The function options is a list that contains a number of default options. See help("options") or simply type options() to get an idea of what we can configure. In my .Rprofile file, we have the line

options(prompt="R> ", digits=4, show.signif.stars=FALSE)

This changes three features.

  • The R prompt, from the boring > to the exciting R> .
  • The number of digits displayed.
  • Removing the stars after significant -values.

Typically we want to avoid adding options to the start-up file that make our code non-portable. For example, adding

options(stringsAsFactors=FALSE)

to your start-up script has knock-on effects for read.table and related functions including read.csv , making them convert text strings into characters rather than into factors as is default. This may be useful for you, but it is dangerous as it may make your code less portable. 3.3.2.2 Setting the CRAN mirror

To avoid setting the CRAN mirror each time you run install.packages you can permanently set the mirror in your .Rprofile .

## local creates a new, empty environment
## This avoids polluting the global environment with
## the object r
local({
  r = getOption("repos")             
  r["CRAN"] = "https://cran.rstudio.com/"
  options(repos = r)
})

The RStudio mirror is a virtual machine run by Amazon's EC2 service, and it syncs with the main CRAN mirror in Austria once per day. Since RStudio is using Amazon's CloudFront, the repository is automatically distributed around the world, so no matter where you are in the world, the data doesn't need to travel very far, and is therefore fast to download. 3.3.2.3 The fortunes package

This section illustrate what .Rprofile does with reference to a package that was developed for fun. The code below could easily be altered to automatically connect to a database, or ensure that the latest packages have been downloaded.

The fortunes package contains a number of memorable quotes that the community has collected over many years, called R fortunes. Each fortune has a number. To get fortune number , for example, enter

fortunes::fortune(50)

It is easy to make R print out one of these nuggets of truth each time you start a session, by adding the following to ~/.Rprofile :

if(interactive()) 
  try(fortunes::fortune(), silent=TRUE)

The interactive function tests whether R is being used interactively in a terminal. The fortune function is called within try . If the fortunes package is not available, we avoid raising an error and move on. By using :: we avoid adding the fortunes package to our list of attached packages..

The function .Last , if it exists in the .Rprofile , is always run at the end of the session. We can use it to install the fortunes package if needed. To load the package, we use require , since if the package isn't installed, the require function returns FALSE and raises a warning.

.Last = function() {
  cond = suppressWarnings(!require(fortunes, quietly=TRUE))
  if(cond) 
    try(install.packages("fortunes"), silent=TRUE)
  message("Goodbye at ", date(), "\n")
}
3.3.2.4 Useful functions

You can also load useful functions in .Rprofile . For example, we could load the following two functions for examining data frames:

## ht == headtail
ht = function(d, n=6) rbind(head(d, n), tail(d, n))
  
## Show the first 5 rows & first 5 columns of a data frame
hh = function(d) d[1:5, 1:5]

and a function for setting a nice plotting window:

setnicepar = function(mar = c(3, 3, 2, 1), mgp = c(2, 0.4, 0), 
                      tck = -.01, cex.axis = 0.9, 
                      las = 1, mfrow = c(1, 1), ...) {
    par(mar = mar, mgp = mgp, tck = tck,
        cex.axis = cex.axis, las = las, 
        mfrow = mfrow, ...)
}

Note that these functions are for personal use and are unlikely to interfere with code from other people. For this reason even if you use a certain package every day, we don't recommend loading it in your .Rprofile . Also beware the dangers of loading many functions by default: it may make your code less portable. Another downside of putting functions in your .Rprofile is that it can clutter-up your work space: when you run the ls() command, your .Rprofile functions will appear. Also if you run rm(list=ls()) , your functions will be deleted.

One neat trick to overcome this issue is to use hidden objects and environments. When an object name starts with . , by default it doesn't appear in the output of the ls() function

.obj = 1
".obj" %in% ls()
## [1] FALSE

This concept also works with environments. In the .Rprofile file we can create a hidden environment

.env = new.env()

and then add functions to this environment

.env$ht = function(d, n = 6) rbind(head(d, n), tail(d, n))

At the end of the .Rprofile file, we use attach , which makes it possible to refer to objects in the environment by their names alone.

attach(.env)
3.3.3 The .Renviron file

The .Renviron file is used to store system variables. It follows a similar start up routine to the .Rprofile file: R first looks for a global .Renviron file, then for local versions. A typical use of the .Renviron file is to specify the R_LIBS path

## Linux
R_LIBS=~/R/library

## Windows
R_LIBS=C:/R/library

This variable points to a directory where R packages will be installed. When install.packages is called, new packages will be stored in R_LIBS .

Another common use of .Renviron is to store API keys that will be available from one session to another. 4 The following line in .Renviron , for example, sets the ZEIT_KEY environment variable which is used in the package diezeit package:

ZEIT_KEY=PUT_YOUR_KEY_HERE

You will need to sign-in and start a new R session for the environment variable (accessed by Sys.getenv ) to be visible. To test if the example API key has been successfully added as an environment variable, run the following:

Sys.getenv("ZEIT_KEY")

Use of the .Renviron file for storing settings such as library paths and API keys is efficient because it reduces the need to update your settings for every R session. Furthermore, the same .Renviron file will work across different platforms so keep it stored safely. 3.3.4 Exercises

  1. What are the three locations where they are stored? Where are these locations on your computer?
  2. For each location, does a .Rprofile or .Renviron file exist?
  3. Create a .Rprofile file in your current working directory that prints the message Happy efficient R programming each time you start R at this location.

[Jul 30, 2019] Python is overrated

Notable quotes:
"... R commits a substantial scale crime by being so dependent on memory-resident objects. Python commits major scale crime with its single-threaded primary interpreter loop. ..."
Jul 29, 2019 | developers.slashdot.org

epine ( 68316 ), Monday July 29, 2019 @05:48PM ( #59008600 ) Score: 3 )

Jul 30, 2019 | developers.slashdot.org

I had this naive idea that Python might substantially displace R until I learned more about the Python internals, which are pretty nasty. This is the new generation's big data language? If true, sure sucks to be young again.

Python isn't even really used to do big data. It's mainly used to orchestrate big data flows on top of other libraries or facilities. It has more or less become the lingua franca of high-level hand waving. Any real grunt is far below.

R commits a substantial scale crime by being so dependent on memory-resident objects. Python commits major scale crime with its single-threaded primary interpreter loop.

If I move away from R, it will definitely be Julia for any real work (as Julia matures, if it matures well), and not Python.

[Dec 06, 2017] Install R on RedHat errors on dependencies that don't exist

Highly recommended!
Dec 06, 2017 | stackoverflow.com

Jon ,Jul 11, 2014 at 23:55

I have installed R before on a machine running RedHat EL6.5, but I recently had a problem installing new packages (i.e. install.packages()). Since I couldn't find a solution to this, I tried reinstalling R using:
sudo yum remove R

and

sudo yum install R

But now I get:

....
---> Package R-core-devel.x86_64 0:3.1.0-5.el6 will be installed
--> Processing Dependency: blas-devel >= 3.0 for package: R-core-devel-3.1.0-5.el6.x86_64
--> Processing Dependency: libicu-devel for package: R-core-devel-3.1.0-5.el6.x86_64
--> Processing Dependency: lapack-devel for package: R-core-devel-3.1.0-5.el6.x86_64
---> Package xz-devel.x86_64 0:4.999.9-0.3.beta.20091007git.el6 will be installed
--> Finished Dependency Resolution
Error: Package: R-core-devel-3.1.0-5.el6.x86_64 (epel)
           Requires: blas-devel >= 3.0
Error: Package: R-core-devel-3.1.0-5.el6.x86_64 (epel)
       Requires: lapack-devel
Error: Package: R-core-devel-3.1.0-5.el6.x86_64 (epel)
       Requires: libicu-devel
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

I already checked, and blas-devel is installed, but the newest version is 0.2.8. Checked using:

yum info openblas-devel.x86_64

Any thoughts as to what is going wrong? Thanks.

Scott Ritchie ,Jul 12, 2014 at 0:31

A cursory search of blas-devel in google shows that the latest version is at least version 3.2. You probably used to have an older version of R installed, and the newer version depends on a version of BLAS not available in RedHat? – Scott Ritchie Jul 12 '14 at 0:31

bdemarest ,Jul 12, 2014 at 0:31

Can solve this by sudo yum install lapack-devel , etc.. until the errors stop. – bdemarest Jul 12 '14 at 0:31

Jon ,Jul 14, 2014 at 4:08

sudo yum install lapack-devel does not work. Returns: No package lapack-devel available. Scott - you are right that blas-devel is not available in yum. What is the best way to fix this? – Jon Jul 14 '14 at 4:08

Owen ,Aug 27, 2014 at 18:33

I had the same issue. Not sure why these packages are missing from RHEL's repos, but they are in CentOS 6.5, so the follow solution works, if you want to keep things in the package paradigm:
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/lapack-devel-3.2.1-4.el6.x86_64.rpm
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/blas-devel-3.2.1-4.el6.x86_64.rpm
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/texinfo-tex-4.13a-8.el6.x86_64.rpm
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libicu-devel-4.2.1-9.1.el6_2.x86_64.rpm
sudo yum localinstall *.rpm

cheers


UPDATE: Leon's answer is better -- see below.

DavidJ ,Mar 23, 2015 at 19:50

When installing texinfo-tex-5.1-4.el7.x86_654, it complains about requiring tex(epsd.tex), but I've no idea which package supplies that. This is on RHEL7, obviously (and using CentOS7 packages). – DavidJ Mar 23 '15 at 19:50

Owen ,Mar 24, 2015 at 21:07

Are you trying to install using rpm or yum? yum should attempt to resolve dependencies. – Owen Mar 24 '15 at 21:07

DavidJ ,Mar 25, 2015 at 14:18

It was yum complaining. Adding the analogous CentOS repo to /etc/yum.repos.d temporarily and then installing just the missing dependencies, then removing it and installing R fixed the issue. It is apparently a issue/bug with the RHEL package dependencies. I had to be careful to ensure the all other packages came from the RHEL repos, not CentOS, hence not a good idea to install R itself when the CentOS repo is active. – DavidJ Mar 25 '15 at 14:18

Owen ,Mar 26, 2015 at 4:49

Glad you figured it out. When I stumbled on this last year I was also surprised that the Centos repos seemed more complete than RHEL. – Owen Mar 26 '15 at 4:49

Dave X ,May 28, 2015 at 19:33

They are in the RHEL optional RPMs. See Leon's answer. – Dave X May 28 '15 at 19:33

Leon ,May 21, 2015 at 18:38

Do the following:
  1. vim /etc/yum.repos.d/redhat.repo
  2. Change enabled = 0 in [rhel-6-server-optional-rpms] section of the file to enabled=1
  3. yum install R

DONE!

I think I should give reference to the site of solution:

https://bluehatrecord.wordpress.com/2014/10/13/installing-r-on-red-hat-enterprise-linux-6-5/

Dave X ,May 28, 2015 at 19:31

Works for RHEL7 with [rhel-7-server-optional-rpms] change too. – Dave X May 28 '15 at 19:31

Jon ,Aug 4, 2014 at 4:49

The best solution I could come up with was to install from source. This worked and was not too bad. However, now it isn't in my package manager.

[Dec 06, 2017] Download RStudio Server -- RStudio

Dec 06, 2017 | www.rstudio.com
RStudio Server v0.99 requires RedHat or CentOS version 5.4 (or higher) as well as an installation of R. You can install R for RedHat and CentOS using the instructions on CRAN: https://cran.rstudio.com/bin/linux/redhat/README .

RedHat/CentOS 6 and 7

To download and install RStudio Server open a terminal window and execute the commands corresponding to the 32 or 64-bit version as appropriate.

64bit
Size: 43.5 MB MD5: 1e973cd9532d435d8a980bf84ec85c30 Version: 1.1.383 Released: 2017-10-09

$ wget https://download2.rstudio.org/rstudio-server-rhel-1.1.383-x86_64.rpm
$ sudo yum install --nogpgcheck rstudio-server-rhel-1.1.383-x86_64.rpm

See the Getting Started document for information on configuring and managing the server.

Read the RStudio Server Professional Admin Guide for more detailed instructions.

[Dec 06, 2017] The difficulties of moving from Python to R

Dec 06, 2017 | blog.danwin.com

This post is in response to: Python, Machine Learning, and Language Wars , by Sebastian Raschka

As someone who's switched from Ruby to Python (because the latter is far easier to teach, IMO) and who has also put significant time into learning R just to use ggplot2, I was really surprised at the lack of relevant Google results for "switching from python to r" – or similarly phrased queries. In fact, that particular query will bring up more results for R to Python , e.g. " Python Displacing R as The Programming Language For Data ". The use of R is so ubiquitous in academia (and in the wild, ggplot2 tends to wow nearly on the same level as D3) that I had just assumed there were a fair number of Python/Ruby developers who have tried jumping into R. But there aren't minimaxir's guides are the most and only comprehensive how-to-do-R-as-written-by-an-outsider guides I've seen on the web.

By and far, the most common shift seems to be that of Raschka's – going from R to Python:

Well, I guess it's no big secret that I was an R person once. I even wrote a book about it So, how can I summarize my feelings about R? I am not exactly sure where this quote is comes from – I picked it up from someone somewhere some time ago – but it is great for explaining the difference between R and Python: "R is a programming language developed by statisticians for statisticians; Python was developed by a computer scientist, and it can be used by programmers to apply statistical techniques." Part of the message is that both R and Python are similarly capable for "data science" tasks, however, the Python syntax simply feels more natural to me – it's a personal taste.

That said, one of the things I've appreciated about R is how it "just works" I usually install R through Homebrew, but installing RStudio via point and click is also straightforward . I can see why that's a huge appeal for both beginners and people who want to do computation but not necessarily become developers. Hell, I've been struggling for what feels like months to do just the most rudimentary GIS work in Python 3 . But in just a couple weeks of learning R – and leveraging however it manages to package GDAL and all its other geospatial dependencies with rgdal – been able to create some decent geospatial visualizations (and queries) :

... ... ...

I'm actually enjoying plotting with Matplotlib and seaborn, but it's hard to beat the elegance of ggplot2 – it's worth learning R just to be able to read and better understand Wickham's ggplot2 book and its explanation of the "Grammar of Graphics" . And there's nothing else quite like ggmap in other languages.

Also, I used to hate how <- was used for assignment. Now, that's one of the things I miss most about using R. I've grown up with single-equals-sign assignment in every other language I've learned, but after having to teach some programming the difference between == and = is a common and often hugely stumping error for beginners. Not only that, they have trouble remembering how assignment even works, even for basic variable assignment I've come to realize that I've programmed so long that I immediately recognize the pattern, but that can't possibly be the case for novices, who if they've taken general math classes, have never seen the equals sign that way. The <- operator makes a lot more sense though I would have never thought that if hadn't read Hadley Wickham's style guide .

Speaking of Wickham's style guide, one thing I wish I had done at the very early stages of learning R is to have read Wickham's Advanced R book – which is free online (and contains the style guide). Not only is it just a great read for any programmer, like everything Wickham writes, it is not at all an "advanced" book if you are coming from another language. It goes over the fundamentals of how the language is designed. For example, one major pain point for me was not realizing that R does not have scalars – things that appear to be scalars happen to be vectors of length one. This is something Wickham's book mentions in its Data structures chapter .

Another vital and easy-to-read chapter: Wickham's explanation of R's non-standard evaluation has totally illuminated to me why a programmer of Wickham's caliber enjoys building in R, but why I would find it infuriating to teach R versus Python to beginners.

(Here's another negative take on non-standard evaluation , by an R-using statistician)

FWIW, Wickham has posted a repo attempting to chart and analyze various trends and metrics about R and Python usage . I won't be that methodical; on Reddit, r/Python seems to be by far the biggest programming subreddit. At the time of writing, it has 122,690 readers . By comparison, r/ruby and r/javascript have 31,200 and 82,825 subscribers, respectively. The R-focused subreddit, r/rstats , currently has 8,500 subscribers.

The Python community is so active on Reddit that it has its own learners subreddit – r/learnpython – with 54,300 subscribers .

From anecdotal observations, I don't think Python shows much sign of diminishing popularity on Hacker News, either. Not just because Python-language specific posts keep making the front page, but because of the general increased interest in artificial intelligence, coinciding with Google's recent release of TensorFlow , which they've even quickly ported to Python 3.x .

[Sep 18, 2016] R Weekly

Sep 18, 2016 | tm.durusau.net
September 12th, 2016 R Weekly

A new weekly publication of R resources that began on 21 May 2016 with Issue 0 .

Mostly titles of post and news articles, which is useful, but not as useful as short summaries, including the author's name.

Learning R and Perl - Stack Overflow

I can recommend Penn University's Introductory Course on R.

The ggplot chapter alone is worth reading - I found ggplot very confusing but this is a great explanation.

Getting Started with R – RStudio Support

> Garrett Grolemund,

New to R?

There are hundreds of websites that can help you learn the language. Here's how you can use some of the best to become a productive R programmer.

Start by downloading R and RStudio.

Learn the basics

Visit Try R to learn how to write basic R code. These interactive lessons will get you writing real code in minutes, and they'll tell you immediately when you go wrong.

Broaden your skills

Work through The Beginner's Guide to R by Computerworld Magazine. This 30 page guide will show you how to install R, load data, run analyses, make graphs, and more.

Practice good habits

Read the Google R Style Guide for advice on how to write readable, maintainable code. This is how other R users will expect your code to look when you share it.

Look up help

When you need to learn more about an R function or package, visit Rdocumentation.org, a searchable database of R documentation. You can search for R packages and functions, look at package download statistics, and leave and read comments about R functions.

Ask questions

Seek help at StackOverflow, a searchable forum of questions and answers about computer programming. StackOverflow has answered (and archived) over 40,000 questions related to R programming. You can browse StackOverflow's archives and see which answers have been upvoted by users, or you can ask your own R related questions and wait for a response.

If you a have question that is more about statistical methodology there are also plenty of R users active on the the CrossValidated Q&A community.

Keep tabs on the R community

Read R bloggers, a blog aggregator that reposts R related articles from across the web. A good place to find R tutorials, announcements, and other random happenings.

Deepen your expertise

Once you've gained some familiarity with R, The R Inferno provides an entertaining roadmap to some of the deeper subtleties of the language and how to work with it most effectively.

This blog post by Noam Ross also provides valuable advice for writing fast R code.

Got R down? Give Shiny a try

Now that you know R, work through our Shiny lessons to learn how to make interactive web apps with R.

[Jun 10, 2015] The R Language The Good The Bad And The Ugly - John Cook

"...May be a bit old, but a good talk on the quirks and niceties of R"
Mar 27, 2013 | YouTube

Here's a description of John's talk from GOTO Aarhus 2012: R is a domain-specific language for analyzing data. Why does data analysis need its own DSL? What does R do well and what does it do poorly? How can developers take advantage of R's strengths and mitigate its weaknesses? This talk will give some answers to these questions.

Jesus M. Castagnetto

May be a bit old, but a good talk on the quirks and niceties of R

[Jun 09, 2015] The R Programming Language - Free Computer, Programming, Mathematics, Technical Books, Lecture Notes and Tutorials

Brought To You By the Letter R: Microsoft Acquiring Revolution Analytics

timothy from the interesting-choice-of-letter dept.

theodp writes Maybe Bill Gates' Summer Reading this year will include The Art of R Programming. Pushing further into Big Data, Microsoft on Friday announced it's buying Revolution Analytics, the top commercial provider of software and services for the open-source R programming language for statistical computing and predictive analytics. "By leveraging Revolution Analytics technology and services," blogged Microsoft's Joseph Sirosh, "we will empower enterprises, R developers and data scientists to more easily and cost effectively build applications and analytics solutions at scale." Revolution Analytics' David Smith added, "Now, Microsoft might seem like a strange bedfellow for an open-source company [RedHat:Linux as Revolution Analytics:R], but the company continues to make great strides in the open-source arena recently." Now that it has Microsoft's blessing, is it finally time for AP Statistics to switch its computational vehicle to R?

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

[Dec 06, 2017] Install R on RedHat errors on dependencies that don't exist Published on Dec 06, 2017 | stackoverflow.com

Sites

Top articles

Sites

Documentation

R The R Base Package

Google has a well known R style guide reflecting internal use of the language.

Youtube videos

R Learning Links (Rutgers University)
Guides and Tutorials
  • Starter Kit – UCLA Statistical Computing has compiled excellent overviews of not only R, but also, SAS, SPSS, and Stata. Class notes, learning modules, and downloadable books.
  • Cookbook for R - wiki style information
  • R Programming Wikibook - a practical guide to the R programming language.
  • R Tutorial Series - short tutorials on common topics.
  • R Videos – from Texas A&M, covers all the basics.
  • Manuals, FAQs, Listservs and more are available from http://www.r-project.org/. The R Reference Card is a quite handy summary.
  • Quick-R is a guide for experienced users of other stats packages like SAS, SPSS, or Stata.
  • Springer Use R! series (available from Springerlink) has many useful guides to using R in different fields
Searching for R on the Internet
More Information

Web resources

Problems with R


>

Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2018 by Dr. Nikolai Bezroukov. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) in the author free time and without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: October, 19, 2019