Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me to write R code to perform the following tasks. Write and test the function even_odd() that accepts a vector of integers as

Please help me to write R code to perform the following tasks.

Write and test the function even_odd() that accepts a vector of integers as input and returns a two-element vector containing the number of evens and the number of odds. The function would be used as follows:

even_odd(9:1) # returns 4 5 (4 evens, 5 odds)

even_odd(c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) # returns 4 5 (4 evens, 5 odds)

Zero is not considered an even number. Use the ifelse() and sum() functions inside the body of the even_odd function.

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

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions

Question

Explain the ways in which ROI can be improved.

Answered: 1 week ago