How to do it…

To check the input data types, the required function is is.x, where x is a placeholder for character, numeric, logical, vector, matrix, and so on. Using this function, the data type and data structure can be easily assessed. You will use the is.x type of function in the body of the fDescriptive function as follows:

    fDescriptive <- function(numVec, type = "classical"){
type <- tolower(type)
if(is.numeric(numVec) & is.vector(numVec)){
avg <- mean(numVec)
std <- sd(numVec)
med <- median(numVec)
medad <- mad(numVec)
out1 <- c(mean = avg, sd = std)
out2 <-c(median = med, mad = medad)
if(type== "classical")
return(out1)
else if (type == "robust")
return(out2)
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset