Posts

Showing posts from May, 2026

Programs to try using lists in R - Assignment 6

  1. Student Grade Card System Problem Statement Create a list to store the details of a student including: Roll Number Name Marks in three subjects (stored as a vector) Attendance Percentage Perform the following operations: Display all student details. Calculate the total marks. Calculate the average marks. Determine whether the student has passed ( mark >=40 , max marks=100) 2. Shopping Cart Management System Problem Statement Create a list containing: Customer Name Product Names (vector) Product Prices (vector) Quantity Purchased (vector) Perform the following operations: Display the products purchased. Calculate the amount for each product. Calculate the total bill. Find the most expensive item. 3. Employee Payroll System Problem Statement Create a list storing: Employee ID Employee Name Basic Salary Allowances Deductions Calculate: Gross Salary Net Salary Annual Salary Display all details. 4. Cricket Team ...

Sample Programs Using Matrices in R

  Sample Programs Using Matrices in R The following programs demonstrate practical numerical applications of matrices suitable for undergraduate laboratories. 1. Student Mark Analysis Problem Marks of 4 students in 3 subjects are stored in a matrix. Find: Total marks of each student. Average marks of each student. Highest mark in each subject. Class average in each subject. Program marks <- matrix( c(85,90,78, 92,88,80, 75,82,85, 95,91,89), nrow=4, byrow=TRUE ) print(marks) # Total marks of students totals <- rowSums(marks) # Average marks of students averages <- rowMeans(marks) # Highest mark in each subject highest <- apply(marks,2,max) # Subject averages subject_avg <- colMeans(marks) cat("Total Marks:\n") print(totals) cat("Average Marks:\n") print(averages) cat("Highest Mark in Each Subject:\n") print(highest) cat("Subject Averages:\n") print(subject_avg) 2. Matrix Multiplication Problem ...

Matrix in R

  Matrix in R Introduction A matrix is a two-dimensional homogeneous data structure in R used to store elements of the same data type arranged in rows and columns. A matrix is one of the most important data structures in R and is extensively used in: Mathematics Statistics Machine Learning Image Processing Scientific Computing Data Analysis For example, marks of students in different subjects can be represented as a matrix: Maths Physics Chemistry Student1      85 90 88 Student2 92 87 95 Student3 78 80 82 Characteristics of Matrices Two-dimensional structure. Homogeneous (all elements have the same type). Elements are arranged in rows and columns. Elements are stored column-wise by default. Support element-wise arithmetic operations. Support matrix operations such as transpose and multiplication. Creating Matrices Matrices are created using the matrix() function. Syntax matrix(data, nrow, ncol, byrow=FALSE) where: data :...