Return the median value or the modal value of a vector, depending on whether the vector is numeric or a factor.

centre(x, ...)

# S3 method for numeric
centre(x, na.rm = TRUE, ...)

# S3 method for factor
centre(x, na.rm = TRUE, ...)

Arguments

x

an object for which a method has been defined, or a numeric vector containing the values whose median is to be computed.

...

potentially further arguments for methods; not used in the default method.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

Value

the median value for objects of the class integer or double. The modal value for objects of class factor.

Examples

vec <- c(-3, -2, 0, 1, 1, 3) centre(vec)
#> [1] 0.5
vec <- c(-3, -2, 0, 1, 1, 3) vec <- as.factor(vec) centre(vec)
#> [1] 1 #> Levels: -3 -2 0 1 3
dados <- st_drop_geometry(centro_2015)
#> Error in st_drop_geometry(centro_2015): could not find function "st_drop_geometry"
centre(dados$padrao)
#> Error in centre(dados$padrao): object 'dados' not found