Question: Write a function called qcd(), short for quartile coefficient of dispersion. This function takes two arguments: the required x, which is a numeric vector; and
Write a function called qcd(), short for quartile coefficient of dispersion. This function takes two arguments: the required x, which is a numeric vector; and the optional na.rm, which indicates whether NAs should be removed from x. The default value for this argument should be FALSE. The function returns the single numeric value that is the ratio of the interquartile range (75th percentile minus 25th percentile) to the sum of the lower (25th percentile) and upper (75th) percentiles. Note: the function IQR(x, na.rm = FALSE) returns the interquartile range of the vector x. Also, the function quantile(x, 0.25) returns the 25th percentile. In addition, check that the input for x is numeric and if not terminate execution and provide an informative error message. Write a function called qcd(), short for quartile coefficient of dispersion. This function takes two arguments: the required x, which is a numeric vector; and the optional na.rm, which indicates whether NAs should be removed from x. The default value for this argument should be FALSE. The function returns the single numeric value that is the ratio of the interquartile range (75th percentile minus 25th percentile) to the sum of the lower (25th percentile) and upper (75th) percentiles. Note: the function IQR(x, na.rm = FALSE) returns the interquartile range of the vector x. Also, the function quantile(x, 0.25) returns the 25th percentile. In addition, check that the input for x is numeric and if not terminate execution and provide an informative error message
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
