Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the difference between (d) and (e)? How to display the results in consol

ID: 3271513 • Letter: W

Question

What is the difference between (d) and (e)? How to display the results in console in R? 1. (13 Points-3 for comments) Write an R program that performs the following tasks: 15 27 9 and b-14 9 (a) (2 Points for code) Construct the vectors a = 2 (b) (2 Points-1 for code) Find the sum of a and b. (c) (2 Pots-1 for code) Find the difference a - b. (d) (2 Points 1 for code) Find the dot product of a and b. (e) (2 Points 1 for code)Find the element-wise product of a and b. In your code, include comments (3 Points), and make sure that your code includes statements for each of parts a)-e) that tell R to display the results in the console.

Explanation / Answer

a)

a <- c(9,3,2,7,11)
> b <- c(15,27,14,9,8)

b)


> a+b
[1] 24 30 16 16 19

c)


> a-b
[1] -6 -24 -12 -2   3

d)

> a %*% b
     [,1]
[1,] 395

e)

> a *b
[1] 135 81 28 63 88

note d ) is dot-product which is actually sum of element-wise product of each row . it is scalar quantity

where as element-wise product is vector with product of two corresponding row.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote