Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose we define myvec below. Which of the following blocks of R code will yield the vector [ 2 - 9 9 6 - 9

Suppose we define myvec below. Which of the following blocks of R code will yield the vector [2-996-9910]?
myvec <- c(1,2,3,4,5)
Please try to complete this problem without looking at RStudio (believe it or not, this will help strengthen your learning retention)!
myfunc <-\(x) if (x %%2==0)-99 else x *2
map_int(myvec, myfunc)
myfunc <- function (x) if (x %%2==0)-99 else x *2
map_int(myvec, myfunc)
if_else(myvec %%2==0,-99, myvec *2)
myfunc <- function (x) if (x %%2==0)-99 else x *2
map(myvec, myfunc)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are some things you could do to become a better listener?

Answered: 1 week ago

Question

Guidelines for Informative Speeches?

Answered: 1 week ago