Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebasing to include the merged getting started chapter in reviewing bugs branch #3

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 27 additions & 40 deletions 02-getting_started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,60 @@

These instructions cover how to install $\textsf{R}$ in Windows. The tools required to build $\textsf{R}$ and $\textsf{R}$ packages in Windows are also discussed.

## Installing $\textsf{R}$

To install $\textsf{R}$ in Windows follow these steps:

1. Go to https://cran.r-project.org.

2. Select `Download R for Windows`. You will be directed to a page which shows `Subdirectories` for installing R on Windows.

3. Select `base` subdirectory. Alternatively, you can select `install R for the first time`, it leads to the same page. The current official stable release distribution of $\textsf{R}$ can be downloaded from here. (Along with the link to the current official stable release, links to the development snapshot build and to the previous releases, are also available on this page).
## General instructions

4. This distribution is distributed as an installer `R-x.y.z-win.exe`. The `x.y.z` in the $\textsf{R}$ system version represent the major, minor, and patchlevel numbers, respectively.
1. If you install the latest version or R-patched or R-devel, it will not over-write the previous installation(s) in your Windows machine.

5. This has to be run in the Windows-style installer.
2. R uses a ‘major.minor.patchlevel’ version numbering scheme. Accordingly there are three main releases of $\textsf{R}$ available to install:

6. Select the language while installing, read the public license information, and select destination location to the start the installation. You will be prompted to select components at this stage: `User installation`, `32-bit User installation`, `64-bit User installation`, or `Custom installation`. The default option may be opted for the questions from this step onwards.
* The official release (`r-release`),

7. Complete the installation.
* The patched release (`r-patched`), and

## General instructions
* The development (`r-devel`) release.

1. The $\textsf{R}$ executable downloaded by following the above steps, is the binary distribution of `R-x.y.z`, which can run on Windows XP and above versions (including 64-bit versions of Windows). It can run on ix86 and x86_64 chips.
The `r-devel` is the next minor or eventually major release development version of $\textsf{R}$. Mostly, bug fixes are introduced in `r-patched`, while `r-devel` is for introducing new features.

2. There are two versions of the $\textsf{R}$ executable, the 32-bit version (in `R-x.y.z\bin\i386`) and the 64-bit version (in `R-x.y.z\bin\x64`). On the 32-bit versions of Windows, by default only the former gets installed, whereas on the 64-bit versions, both get installed.
## Installing $\textsf{R}$

3. If there is already a previous version of R installed in your system and you want to retain the packages installed in it, then uninstall the previous version of $\textsf{R}$ (from the Control Panel) and install the new one. In the new installation, copy any installed packages to the library folder and run `update.packages(checkBuilt=TRUE, ask=FALSE)` in the new $\textsf{R}$.
1. The binary builds of $\textsf{R}$ for Windows can be downloaded and installed from [here](https://cran.r-project.org/bin/windows/base/). Along with the link to the latest stable release, this page also contains links to the binary builds of r-patched and r-devel.

4. If there are different versions of R installed, then they are present in parallel folders. Hence, earlier versions can also be retained if you wish to keep them.

5. When there is a change in the minor version of $\textsf{R}$ (say, from 4.0.3 to 4.1.0), then the library names (folder `R\win-library\x.y` of your home directory, `R\win64-library\x.y` on 64-bit builds), will need to be updated too. For doing this, copy (say) `R\win-library\4.0` to `R\win-library\4.1` and then run the `update.packages(checkBuilt=TRUE, ask=FALSE)` command.
2. Click on the download links to download an executable installer.

6. Daily [tarballs](https://stat.ethz.ch/R/daily/) are available for the patched version of the current release (`r-patched`), and the development version of the current release (`r-devel`). The same are also available via the [R Subversion repository](https://svn.R-project.org/R/)
3. Select the language while installing, read the public license information, and select destination location to the start the installation. You will be prompted to select components at this stage: `User installation`, `32-bit User installation`, `64-bit User installation`, or `Custom installation`. The default option may be opted for the questions from this step onwards to complete the installation.

## Building $\textsf{R}$ and $\textsf{R}$ packages

### What tools you need to build $\textsf{R}$ from source on Windows?

1. `RTools` is the [subdirectory](https://cran.r-project.org/bin/windows/Rtools/) which you want to build $\textsf{R}$ or your own $\textsf{R}$ package(s) on Windows.
1. [RTools](https://github.com/r-windows/docs/blob/master/faq.md#what-is-rtools) is the toolchain bundle that you can use to build $\textsf{R}$ base and $\textsf{R}$ packages containing compiled code, on Windows.

2. You also need a distribution of $\LaTeX$ installed for building $\textsf{R}$ and checking packages. The `MiKTeX` distribution of $\LaTeX$ that is used on CRAN can be downloaded from https://miktex.org.

### How to setup `RTools`?

1. The executable version of `RTools` that is specific to your requirements can be downloaded from https://cran.r-project.org/bin/windows/Rtools/ and run in the Windows-style installer.
1. The latest version of `RTools` can be downloaded from https://cran.r-project.org/bin/windows/Rtools/ and run in the Windows-style installer. You will need to know if you have a 32-bit or 64-bit Windows machine (right-click `This PC` in Windows Explorer and check the properties if you are unsure).

2. Don't forget to add `RTools` to the path as documented on the download page.

2. After completing the installation, you need to put the location of the RTools $\textit{make}$ $\textit{utilities}$ on the `PATH`. For doing this, exceute the following commands in $\textsf{R}$:
### How to build $\textsf{R}$?

```{r, results='hide'}
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
```
To build $\textsf{R}$ for Windows using `RTools` follow the instructions in this [README](https://github.com/r-windows/r-base#readme) file. There are two options available to build $\textsf{R}$. One is the quick development build and the other option is the full installer build.

Restart $\textsf{R}$ now. Verify that $\textit{make}$ can be found using the following command. (The output of the command should show the path where you installed `RTools`):
For development and testing, you need only the quick development build. The quick build avoids building the manuals, which are generally not needed for development and testing.

```{r, results='hide'}
Sys.which("make")
## "C:\\rtools40\\usr\\bin\\make.exe"
```
However, even for the quick build there are some [default requirements](https://github.com/r-windows/r-base/blob/master/quick-build.sh). For instance, `MikTeX` is to be installed in `C:/Program Files` and you have 64-bit $\textsf{R}$. If necessary, these defaults can be customised. The installation path of `MikTex` can be customised [here](https://github.com/r-windows/r-base/blob/50a229fc76c50a5fb42c0daa367466aaf2318171/quick-build.sh#L13) whereas the Windows bit can be customised [here](https://github.com/r-windows/r-base/blob/50a229fc76c50a5fb42c0daa367466aaf2318171/quick-build.sh#L6).

If the above works, then try installing an $\textsf{R}$ package from source:
If you are a maintainer of the Windows CRAN releases then, the full installer build is available for building the complete installer as it appears on CRAN. It will build both the 32-bit and 64-bit $\textsf{R}$, the pdf manuals, and the installer program. You will use this to create the binary builds and not when building $\textsf{R}$ from the source yourself.

```{r, results='hide'}
## install.packages("jsonlite", type = "source") ## An example
```
## See also

If you are successful in installing an $\textsf{R}$ package from source, then the setup for `RTools` is completed.
1. [CRAN official website](https://cran.r-project.org)

### How to build $\textsf{R}$?
2. [R installation and administration manual](https://cran.r-project.org/doc/manuals/r-patched/R-admin.html)

3. [R for Windows FAQ](https://cran.r-project.org/bin/windows/base/rw-FAQ.html)

To build $\textsf{R}$ for Windows using `RTools` follow the instructions in this [readme](https://github.com/r-windows/r-base#readme) file.
4. [Rtools40 manual for Windows](https://cran.r-project.org/bin/windows/Rtools/)

## References (chapterwise or at the end of the guide?)
5. [R FAQ](https://cran.r-project.org/doc/FAQ/R-FAQ.html)