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

Do the coding in R langauge and answers the following questions. Exercise 4.2 a.

ID: 3871703 • Letter: D

Question

Do the coding in R langauge and answers the following questions.

Exercise 4.2 a. Store the vector c(7,1,7,10,5,9,10,3,10,8) as foo. Identify the elements greater than 5 OR equal to 2. Store the vector c(8,8,4,4,5,1,5,6,6,8) as bar. Identify the ele- ments less than or equal to 6 AND not equal to 4. Identify the elements that satisfy (a) in foo AND satisfy (b) in bar. Store a third vector called baz that is equal to the element-wise sum of foo and bar. Determine the following: i. The elements of baz greater than or equal to l b. c. d. equal to 15 The elements of the vector obtained via an element-wise division of baz by foo that are greater than 4 OR less than or equal to 2 ii. Confirm that using the long version in all of the preceding exercises performs only the first comparison (that is, the results each match the first entries of the previously obtained vectors). e.

Explanation / Answer

Solutions :

(a)

foo <- c(7, 1, 7, 10, 5, 9, 10, 3, 10, 8)

foo[foo > 5 | foo == 2]

(b)

bar <- c(8, 8, 4, 4, 5, 1, 5, 6, 6, 8)
bar[bar <= 6 & bar != 4]

(c)

foo <- c(7, 1, 7, 10, 5, 9, 10, 3, 10, 8)

bar <- c(8, 8, 4, 4, 5, 1, 5, 6, 6, 8)

c(foo[foo > 5 | foo == 2] , bar[bar <= 6 & bar != 4])

(d)(i)

bazz <- foo + bar

bazz[bazz >= 14 & bazz != 15]

(d)(ii)

div <- bazz / foo
div[div > 4 | div <= 2]

(e) Not clear. go trough it https://swcarpentry.github.io/r-novice-inflammation/15-supp-loops-in-depth/

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