October 2017
Beginner to intermediate
236 pages
7h 38m
English
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) } }