Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Simran R Programming File

The document is a practical file for a course on R Programming at Delhi Skill and Entrepreneurship University, detailing the history, installation, and basic operations of R. It includes various experiments focusing on creating vectors, performing logical operations, and working with matrices and lists, along with problems and solutions related to these topics. The file serves as a guide for students to learn and apply R programming concepts in statistical computing and data analysis.

Uploaded by

Simran tomar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Simran R Programming File

The document is a practical file for a course on R Programming at Delhi Skill and Entrepreneurship University, detailing the history, installation, and basic operations of R. It includes various experiments focusing on creating vectors, performing logical operations, and working with matrices and lists, along with problems and solutions related to these topics. The file serves as a guide for students to learn and apply R programming concepts in statistical computing and data analysis.

Uploaded by

Simran tomar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

R Programming Practical File

DELHI SKILL AND ENTREPRENEURSHIP UNIVERSITY


G.B. PANT DSEU OKHLA-1 CAMPUS
Department of Computer Science Engineering
B.Tech. (CSE) - 4th Semester
Probability and Statistics
(BT-CS-BS401)

Submitted to: Submitted by:


Mr. Saravanan P. Simran Tomar
Assistant Professor B.Tech. CSE 2nd Year
Roll No. 41721016
EXPERIMENT NO. 1
AIM – History and Installation of R Programming Language. Creating
vectors, sequences and series in R.
Theory:
R is a programming language and environment for statistical computing and graphics. It was created by Ross Ihaka
and Robert Gentleman at the University of Auckland, New Zealand in the mid-1990s. The first version of R was
released in 1995. R is open-source software, which means that it is freely available and can be modified by anyone. It
is based on the S language, which was developed at Bell Laboratories by John Chambers and his colleagues in the
1970s.
R has become one of the most popular languages for data science and statistical analysis. It has a large and active
community of users and developers who contribute to its development and maintenance. The R Project for Statistical
Computing was established in 1997 to provide a central repository for R software and documentation. R has been used
for a wide range of applications, including finance, marketing, biology, and social sciences. It has several integrated
development environments (IDEs) and packages for data visualization, data manipulation, and machine learning.

Installation:
Step-1: Open the web browser and Search https://cran.r-project.org/bin/windows/base/.

Step-2: Click on the Download R link for windows on the left-hand side of the page.
Step-3: Once the download is complete, run the installer and follow the prompts to install R on your computer.
Step-4: After the installation is complete, you can launch R by clicking on the R icon in your applications folder or
start menu.
Problems:
Problem-1:
The weights of five people before and after a diet programme are given in the table:

Read the ‘before’ and ‘after’ values into two different vectors called before and after. Use R to evaluate the amount of
weight lost for each participant. What is the average amount of weight lost?
Solution:

Problem-2:
How would you write a function equivalent to sum((x-mean(x))^2) in a language like C or Java?
Problem-3:
Create the following vectors in R using seq() and rep() :

Solution:
Problem-4:

Solution:
EXPERIMENT NO. 2
AIM – Subsetting, logical operations, matrices and lists in R
Theory:
Subsetting :- In R Programming Language, subsetting allows the user to access elements from an object. It
takes out a portion from the object based on the condition provided. In R, indexing starts from 1.
Logical Operator :- The Logical operators in R programming are used to combine two or more conditions,
and perform the logical operations using & (Logical AND), | (Logical OR) and ! (Logical NOT).
Matrices :- A matrix is a two dimensional data set with columns and rows. A column is a vertical
representation of data, while a row is a horizontal representation of data. A matrix can be created with the
matrix() function. Specify the nrow and ncol parameters to get the amount of rows and columns.
Lists:- Lists are the R objects which contain elements of different types like − numbers, strings, vectors and
another list inside it. A list can also contain a matrix or a function as its elements. List is created using the
list() function.

Problems:
Problem-1:
The built-in vector LETTERS contains the uppercase letters of the alphabet. Produce a vector of (i) the first 12 letters;
(ii) the odd ‘numbered’ letters; (iii) the English consonants.

Problem-2:
The function rnorm() generates normal random variables. For instance, rnorm(10) gives a vector of 10 i.i.d. standard
normals. Generate 20 standard normals, and store them in x. Then obtain subvectors of
(i) the entries in x which are less than 1;
(ii) the entries between -½ and 1;
(iii) the entries whose absolute value is larger than 1.5.
Problem-3:
Construct the matrix:

Show that B×B×B is a scalar multiple of the identity matrix and find the scalar.

Problem-4:
Construct the following matrices:
(i)

(ii)
(iii)

(iv)
(v)

(vi)

Problem-5:
Solve the following system of simultaneous equations using matrix methods:

You might also like