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.
To install R on your Windows, just follow these steps:
Go to the official R Project website (https://cloud.r-project.org) and download the latest version of R for Windows.
To proceed, please click the link labelled “Download R for Windows”.
To proceed, please click the link labelled "install R for the first time."
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.
After executing the installer, you will encounter this screen.
Select your desired language. (Here English) and click on OK button.
And then click on Next button to accept licenses agreements,
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 button to continue installation.
Select Start-up options, then click Next button.
Select Start Menu Folder, then click Next button.
Select Additional Tasks, then click Next button.
Setup has finished installing R for Windows 4.4.2. Click Finish to exit the installer.
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.
C:\Program Files\R\R-4.4.2\bin
) Click OK to close all dialogs and apply the changes.
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
Installing R on Linux is as simple as following three steps.
In the initial step, it is essential to update all necessary files within our system by executing the command sudo apt-get update
.
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
.
In the final step, we need to type R
and hit enter to start using the R editor.
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.
To start working with R, open the R 4.4.2 app from the Start Menu.
Your screen will then appear as shown below.
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
.
Syntax: Rscript filename.R
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
In R, packages are collections of functions, data, and documentation that extend the capabilities of R programming.
Packages are essential for performing specialized tasks, such as data manipulation, visualization, statistical analysis, and machine learning. They are stored in the Comprehensive R Archive Network (CRAN) and can be installed and loaded as needed.
Before using a package, you need to install it using the install.packages() function.
# Installs dplyr package
install.packages("dplyr")
# Installs ggplot2 package
install.packages("ggplot2")
1) Download and install R-Programming environment and install basic packages using install. packages() command in R. View Solution
2) Learn all the basics of R-Programming (Data types, Variables, Operators etc,.) View Solution
3) Write R command to
i) Illustrate summation, subtraction, multiplication, and division operations on vectors using vectors.
ii) Enumerate multiplication and division operations between matrices and vectors in R console View Solution
4) Write R command to
i) Illustrates the usage of Vector subsetting and Matrix subsetting
ii) Write a program to create an array of 3×3 matrixes with 3 rows and 3 columns. View Solution
5) Write an R program to draw i) Pie chart ii) 3D Pie Chart, iii) Bar Chart along with chart legend by considering suitable CSV file View Solution
6) Create a CSV file having Speed and Distance attributes with 1000 records. Write R program to draw
i) Box plots
ii) Histogram
iii) Line Graph
iv) Multiple line graphs
v) Scatter plot
to demonstrate the relation between the cars speed and the distance. View Solution
7) Implement different data structures in R (Vectors, Lists, Data Frames) View Solution
8) Write an R program to read a csv file and analyze the data in the file using EDA (Explorative Data Analysis) techniques. View Solution
9) Write an R program to illustrate Linear Regression and Multi linear Regression considering suitable CSV file View Solution