R_Programming_List of Experiments_update (1)
R_Programming_List of Experiments_update (1)
Unit # 2
11 Solve basic operations on Vectors.
a) Write an R code to create a vector containing numbers from 1 to 10.
b) Display the output and find the length of created vector.
12 Accessing elements of Vector
a) Create a vector containing elements multiple of 5.
b) Access and display all the elements except the 5th element of Vector.
13. Vector indexing with conditions
a) Create a Vector consisting of seven elements ranging from 2 to 50. Extract all
elements greater than 15.
b) Replace all the elements less than 15 with zero.
14. Write R code for the following operations on Vector.
a) Combine two vectors with the same datatypes and different datatypes.
b) Append three new elements to the existing vector.
c) Element-wise multiplication of two vectors.
d) Reverse a Vector.
e) Check for the presence of an element in a Vector.
f) Find the sum and product of elements of a Vector.
g) Create a logical vector for an existing Vector.
15 Apply inbuilt functions on Vectors
a) Sort elements of a vector in increasing and decreasing order.
b) Apply filter to the elements of a vector (based on conditions).
c) Extract all the elements of a vector greater than 25.
d) Extract all the elements that are duplicate in nature.
e) Find the sum, mean & median for the elements of a vector.
16 Matrix Operations
a) Generate /create a matrix with 3 rows and 3 columns of consequetive numbers starting
from 6.
b) Access following
i) Second elements of second row.
ii) Third row
iii) Second column
iv) Modify the last element of matrix with 62.
c) Apply element-wise addition, multiplication, division, and subtraction on two vectors.
17 Find the following for matrix
a) Dimension of a matrix.
b) Determinant of a matrix.
c) Inverse of a matrix.
d) Design diagonal & Identity matrix.
e) Find the sum and mean of a rows and columns for a matrix.
f) Find the combination of two matrices concerning the rows and columns.
Data Frames Operations:
18. Create a data frame for students' information with the headings student_id, student_name,
phone, email_id, address, program, year, CGPA, and number_of_backlogs. Create data frame
of size 10. Perform the following on this data frame.
a) Access column CGPA.
b) Access the information on 5th student
c) Identify the details of students whose CGPA is more than 7.5
d) Add two columns SGPA and Marks to the above data frame.
e) Rename the column Marks to Scores.
f) Add information about 3 new students.
g) Create another data frame with the heads student_id, student_names, father_name, and
mother name. Now merge this new data frame with the previously created data frame.
19. Apply the following operations on the data frame.
a) Create a data frame and convert it to a .csv file.
b) Create a data frame from a CSV file.
c) Transpose of a data frame
d) Find the mean of the column CGPA from the first data frame using $, [[]], and column
index methods.
20. Operations on Factors