Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed
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

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

Introduction To Probability Models

Authors: Sheldon M Ross

10th Edition

0123756863, 9780123756862

More Books

Students also viewed these Mathematics questions

Question

8. What values do you want others to associate you with?

Answered: 1 week ago