0% found this document useful (0 votes)
35 views10 pages

R Programming Lab Assignments 2023

Uploaded by

jitmahee
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)
35 views10 pages

R Programming Lab Assignments 2023

Uploaded by

jitmahee
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

TECHNO INDIA UNIVERSITY

SESSION: - 2023-2025
NAME: -SHASWATI PAUL
YEAR: - 2ND
BATCH: -MCA 2C
STUDENT ID: - 231001271220
SUBJECT: - R Programming Lab
ASSIGNMENT 2
Develop R scripts to solve following problems:
1. To determine the simple interest on a given amount of money
at a given rate of interest for a given period of time.
Code-
principal <- 1000
rate <- 5
time <- 2
simple_interest <- (principal * rate * time) / 100
print(simple_interest)
Output-

2. To determine the stock value of a store of certain item on the


basis of its unit cost and quantities held in the stock.
Code-
unit_cost <- 50
quantity <- 200
stock_value <- unit_cost * quantity
print(stock_value)
Output-
3. To determine the value of an exponential expression of the
form a b on the basis of a given base and the power to be
raised.
Code-
base <- 2
exponent <- 3
result <- base^exponent
print(result)
Output-

4. To determine the area of the walls of a rectangular room and


hence the cost of its painting on the basis of charge per square
unit.
Code-
length <- 10
width <- 8
height <- 3
charge_per_sq_unit <- 5
area <- 2 * (length * height + width * height)
painting_cost <- area * charge_per_sq_unit
print(painting_cost)
Output-
5. To determine the perimeter of a triangular plot
Code-
side1 <- 5
side2 <- 7
side3 <- 9
perimeter <- side1 + side2 + side3
print(perimeter)
Output-

6. To determine the surface volume and area of a sphere


Code-
radius <- 4
surface_area <- 4 * pi * radius^2
volume <- (4/3) * pi * radius^3
print(surface_area)
print(volume)
Output-

∗ radius ∗ θ 360]
7. To determine the arc length of an angle[ Hint: Arc length = 2π

Code-
radius <- 5
angle <- 60
arc_length <- 2 * pi * radius * (angle / 360)
print(arc_length)
Output-

8. To determine the perimeter of the sector of a circle[Hint: The


perimeter of the sector of a circle is the length of two radii

by: 2 ∗ Radius + (( θ 360)2π ∗ Radius )]


along with the arc that makes the sector. It can be obtained

Code-
radius <- 6
angle <- 90
perimeter <- 2 * radius + (angle / 360) * 2 * pi * radius
print(perimeter)
Output-

9. To determine the miles on the basis of given kilometers


Code-
kilometers <- 10
miles <- kilometers * 0.621371
print(miles)
Output-
10. To convert degrees to radians
Code-
degrees <- 180
radians <- degrees * (pi / 180)
print(radians)
Output-

11. To determine the volume a certain mass of gas at a given


temperature and pressure when the volume is known at the
normal pressure and at the absolute temperature.
Code-
volume_initial <- 10
pressure_initial <- 1
temperature_initial <- 273.15

pressure_final <- 2
temperature_final <- 300

volume_final <- (volume_initial * pressure_initial *


temperature_final) / (pressure_final * temperature_initial)
print(volume_final)
Output-
12. For any two numbers P and Q, develop an R script to
determine the P% of Q.
Code-
P <- 20
Q <- 150
result <- (P / 100) * Q
print(result)
Output-

13. For five given numbers, it is required to determine their


standard deviation through a R script.
Code-
numbers <- c(10, 12, 14, 16, 18)
sd_value <- sd(numbers)
print(sd_value)
Output-
14. A salesperson of a firm gets his/her commission in three
parts. The first part is a given percentage of the sales amount
based on the area code of the selling zone,the second part is a
predefined percentage of the sales amount based on his years
in service and third part is the 15% of of the sales value.
Develop an R script to determine the total amount of
commission that a salesperson earns for a given amount of
sale.
Code-
sales_amount <- 10000
area_percentage <- 5
service_years_percentage <- 10
fixed_percentage <- 15

commission <- (sales_amount * area_percentage / 100) +


(sales_amount * service_years_percentage / 100) + (sales_amount
* fixed_percentage / 100)
print(commission)
Output-

an annuity. [Hint: F V = P ∗ (1+r) n−1 r where,P = periodic


15. Develop an R script To determine the Future Value(FV) of

payment, r = interest rate in decimal form and n = No. of


payments ]
Code-
P <- 1000
r <- 0.05
n <- 10
FV <- P * (((1 + r)^n - 1) / r)
print(FV)
Output-

16. To determine the net salary of an employee when it is


known that the employee is eligible to dearness allowance
(DA) of 97% of the basic pay, House Rent Allowance (HRA)
of 57% of the basic pay and medical allowance of Rs.150 . It is
further known that 12% of the basic pay is deducted from the
gross salary for the Employees’ Provident fund (EPF) and Rs.
200 is deducted from the gross pay as the professional tax.
Code-
basic_pay <- 20000

DA <- 0.97 * basic_pay


HRA <- 0.57 * basic_pay
medical_allowance <- 150
gross_salary <- basic_pay + DA + HRA + medical_allowance

EPF <- 0.12 * basic_pay


professional_tax <- 200

net_salary <- gross_salary - EPF - professional_tax


print(net_salary)
Output-

You might also like