0% found this document useful (0 votes)
98 views3 pages

R Programming - Assignment

The document describes an R programming assignment involving vector arithmetic and statistics. It asks the student to: 1) Create vectors a and b of increasing and decreasing sequences, multiply them to create vector d, and find subsets of d. 2) Use d to compute the sum, median, and standard deviation. 3) Perform matrix multiplication on matrices a and b and output the result c.

Uploaded by

Raghav V
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)
98 views3 pages

R Programming - Assignment

The document describes an R programming assignment involving vector arithmetic and statistics. It asks the student to: 1) Create vectors a and b of increasing and decreasing sequences, multiply them to create vector d, and find subsets of d. 2) Use d to compute the sum, median, and standard deviation. 3) Perform matrix multiplication on matrices a and b and output the result c.

Uploaded by

Raghav V
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/ 3

R PROGRAMMING-ASSIGNMENT-1 RAGHAV V

22MBA10001

Problem 2: Create the following vectors in R.

a = (5, 10, 15, 20, ..., 160)

b = (87, 86, 85, ..., 56)

Use vector arithmetic to multiply these vectors and call the result d. Select subsets of d to

identify the following.

(a) What are the 19 th , 20 th , and 21 st elements of d?

(b) What are all of the elements of d which are less than 2000?

(c) How many elements of d are greater than 6000?

Solution:

a=seq(5,160,by=5)

b=seq(87,56,by=-1)

multiply these vectors

d=a*b

print(d)

(a) d[19:21]
(b) d[d<2000]
(c) length(d[d>6000])
Output:

Problem 3: Using d from problem 2, use R to compute the

following statistics of d:

(a) sum

(b) median

(c) standard deviation

Solution code:

sum(d)

median(d)

sd(d)

Output:
Solution Code:

a=matrix(c(7,2,9,4,12,13),ncol = 3)

b=matrix(c(1,2,3,7,8,9,12,13,14,19,20,21),nrow = 3)

#matrix multiplication

c=a%*%b

Output:

You might also like