R Programming Experment For Data Science
R Programming Experment For Data Science
Download and install R- Programming environment and install basic packages using install. Packages
() command in R.
R programming is a very popular language and to work on that we have to install RGui.
Installing R to the local computer is very easy. First, we must know which operating system we are using
so that we can download it accordingly.
The official site https://cloud.r-project.org provides installer files for major operating systems including
Windows, Linux, and Mac OS.
Install R in Windows:
3. Install R
Go to the official R Project website (https://cloud.r-project.org) and download the latest version of R
for Windows.
To proceed, click the link labelled Download R-4.4.2 for Windows. Subsequently, the R Installer File
will begin to download.
Open your downloads folder and double-click on the R installer file that you just downloaded.
You may be required to grant access based on your security configurations. Please permit it and
continue.
Step 3: Install R
You will be prompted to specify the installation directory. The default location is C:\Program Files\R\.
You may retain this setting and continue with the installation by clicking on Next button.
The installer will then prompt you to choose components and where to place shortcuts. Click Next
It is essential to manually set that the PATH environment variable of your system is configured properly.
To add the PATH environment variable, please follow these steps.
Copy the path where R is installed to the bin folder. (Usually, it is in C:\Program Files\R\R-
4.4.2\bin)
Under User and System Variables sections, find and select Path, then click Edit.
After the installation is finished, you can confirm that R has been installed correctly by opening a
command prompt (cmd) and entering the following command:
R --version
Install R in Linux (Ubuntu):
Step 1:
In the initial step, it is essential to update all necessary files within our system by executing the
command sudo apt-get update.
Step 2:
In the second step, we will proceed to install the R programming language on our system by utilizing
the command sudo apt-get install r-base.
Step 3:
In the final step, we need to type R and hit enter to start using the R editor.
Running R:
After installing R in our system, there are several ways to work with R.
To start the R command prompt, just type R in the Windows command prompt. After pressing enter,
the interpreter will open, and you will see a prompt where you can write your code.
Using R Gui app
To start working with R, open the R 4.4.2 app from the Start Menu. Your screen will then appear as
shown below.
R Script File:
The R script file is another method to write our programs (set of instructions).
To create an R Script file, just open a text editor and type in your code. After that, save the file with a .R
extension.
We can run these scripts from the command prompt using the R interpreter called Rscript.
Example:
To start, Open Notepad, type the code, and save the file as first.R, as shown below.
Next, Open the command prompt from your current location and enter the following command
to execute the R script file.
Rscript first.R