Question
Write R functions named my.all and my.any, each with a single argument x, which is a vector of logical values. Print an error message if
Write R functions named my.all and my.any, each with a single argument x, which is a vector of logical values. Print an error message if anything other than a vector of logical values is passed to either function. The function my.all should return TRUE if all of the elements of the vector are TRUE and FALSE otherwise. The function my.any should return TRUE if any of the elements of the vector are TURE and FALSE otherwise. Your R functions should be written without calling the built-in R functions named all or any. Tes your my.all and my.any functions on the following four vectors.
x=c(TRUE,TRUE,TRUE)
y=c(TRUE,TRUE,FALSE)
z=c(FALSE,FALSE,FALSE)
v=c("Cat","Dog","Rhino")
Please write your answer as it would be inserted in R
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started