Question: ANSWER IN R CODING LANGUAGE ONLY. Write a function is_attribute( ) that takes as input: 1: , an object, and at , a character vector

ANSWER IN R CODING LANGUAGE ONLY.

ANSWER IN R CODING LANGUAGE ONLY. Write a function is_attribute( ) that

Write a function is_attribute( ) that takes as input: 1: , an object, and at , a character vector of length 1 (AKA a string). If at is an attribute of x , return TRUE , otherwise output FALSE . If an invalid input is passed for at , throw an error of your choice. For example: > is_attribute(matrix(), "dim") [1] TRUE > is_attribute(matrix(), "class") [1]FME > is_attribute(data.frame(), "class") [1] TRUE > is_attribute{numeric(), "") [1]FME > is_attribute(data.frame()Ir 3) Error in is_attribute(data.frame(), 3) : invalid input for at > is_attribute(list(), C("a", "b")) Error in is_attribute(list(), C("a", "b")) : invalid input for a t > is_attribute(sum, "function"} [1]FME Note: while class is considered an attribute for many object types, such as factors and dataframes, class is not considered an attribute of matrices, lists, or atomic (logical, numeric, and character) vectors. Note that the function c1ass() will still output something for any input object, even NULL

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!