0% found this document useful (0 votes)
11 views2 pages

R Programming Lab-Assignment 2

The document outlines lab assignments for BCA-3A and 3E students at Techno India University, focusing on R programming. It includes tasks for matrix operations, data frame manipulation, and data visualization, such as creating matrices, performing arithmetic operations, and generating scatterplots with ggplot2. Students are required to demonstrate understanding of matrix laws and data handling techniques through coding exercises.

Uploaded by

Rae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

R Programming Lab-Assignment 2

The document outlines lab assignments for BCA-3A and 3E students at Techno India University, focusing on R programming. It includes tasks for matrix operations, data frame manipulation, and data visualization, such as creating matrices, performing arithmetic operations, and generating scatterplots with ggplot2. Students are required to demonstrate understanding of matrix laws and data handling techniques through coding exercises.

Uploaded by

Rae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Techno India University, W.B.

Department of Computer Applications

Introduction to R Programming – LAB Assignments

BCA-3A and 3E

Week 6: Matrix Operations

 Write R program to create a 3x3 matrix m1 with random integer values between 1
and 50.
 Compute inverse of m1
 Create a 3x3 matrix m2 with random integer values between 1 and 50. Write
code to
o add m1 and m2 and store the result in m3, calculate the determinant of m3
o subtract m2 from m1 and store the result in m3, calculate the determinant
of m3
o multiply m1 and m2 and store the result in m3, calculate the determinant
of m3
o element wise multiply m1 and m2 and store the result in m3, calculate the
determinant of m3
 Write R program to prove the laws below using A=m1, B=m2, C= m3
o A+B = B+A →Commutative Law of Matrix Addition
o A+B+C = A +(B+C) = (A+B)+C →Associative law of addition
o ABC = A(BC) = (AB)C →Associative law of multiplication
o A(B+C) = AB + AC →Distributive law of matrix algebra
 Write R program to prove the rules for transposition of matrices:

 (A’)’ = A
 (A+B)’ = A’+B’
 (AB)’ = B’A’
 (ABC) = C’B’A’

Week 7: Data Frame Manipulation

1. Loading Data:
o Download the "mtcars" dataset and store it in a variable called df.
2. Filtering Data:
o Write code to select all rows where the car has more than 100
horsepower.
3. Creating Subsets:
o Create a new data frame df_subset that contains only the mpg, cyl,
and hp columns.
4. Sorting Data:
o Sort df_subset in descending order by hp.

Week 8: Data Visualization

1. Creating a Scatterplot:
o Use the ggplot2 library to create a scatterplot of the mtcars dataset, plotting mpg on
the y-axis and hp on the x-axis.
2. Adding a Trend Line:
o Add a trend line to the scatterplot using a linear regression model.
3. Customizing the Plot:
o Customize the plot by adding a title, axis labels, and applying a theme.

You might also like