logo Hurry, Grab up to 30% discount on the entire course
Order Now logo
1103 Times Downloaded

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Nawaj SareefData mining
(5/5)

956 Answers

Hire Me
expert
Kaleb BryanttManagement
(5/5)

688 Answers

Hire Me
expert
Aarushi YadavEnglish
(5/5)

757 Answers

Hire Me
expert
Miguel OrtizzSocial sciences
(5/5)

943 Answers

Hire Me
R Programming
(5/5)

your vector should throw an error if either a or b contain repeated elements

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

1.          Create a function that takes a vector of numerics as input. It checks the length of the vector. If the length is even, it returns the sum of the vector. If the length is odd, it returns the sum of all of the even numbers of the vector. You may call your function numsum (). Evaluate your function on each of the following vectors:

–            c(1, 2, 3, NA)

–            c(1, 2, 3)

–            c(2, 3, 4, 5, 6)

–            c(2, 3, 4, 5, NA)

–            c(2, 3, 4, NA, 6)

2.          We add a Leap Day on February 29, almost every four years. In the Gregorian calendar three criteria must be taken into account to identify leap years:

–            The year can be evenly divided by 4, is a leap year, unless:

–            The year can be evenly divided by 100, it is NOT a leap year, unless:

–            The year is also evenly divisible by 400. Then it is a leap year.

               This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years

               Write a function that takes the year as input and returns TRUE if it is a leap year and FALSE if it is not a leap year. Evaluate your function at 2, 12, 200, 800.

3.          Create a function that takes two vectors of numerics as input, a and b.

–            Your vector should throw an error if either a or b contain repeated elements.

–            If a number is in a and not b you add 1 to your score.

–            If a number is in b and not a you subtract 1 from your score.

–            If a number is in both a and b you do nothing to your score.

–            The function returns the final score.

–            You may name your function abscore()

 

–            Hint: help("%in%")

(5/5)
Attachments:

Expert's Answer

1103 Times Downloaded

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme