home *** CD-ROM | disk | FTP | other *** search
-
- _S_e_l_e_c_t _O_n_e _o_f _a _L_i_s_t _o_f _A_l_t_e_r_n_a_t_i_v_e_s
-
- switch(EXPR, ...)
-
- _A_r_g_u_m_e_n_t_s:
-
- EXPR : an expression that evaluates to a number or a
- character string
-
- ... : the list of alternatives, given explicitly
-
- _D_e_s_c_r_i_p_t_i_o_n:
-
- switch evaluates EXPR if the value is an integer
- between 1 and nargs()-1 then the corresponding element
- of ... is evaluated and the result returned. If EXPR
- returns a character string then that string is used to
- match the names of the elements in .... If there is an
- exact match then that element is evaluated and the
- result returned.
-
- _E_x_a_m_p_l_e_s:
-
- centre <- function(x, type) {
- switch(type,
- mean=mean(x),
- median=median(x),
- trimmed=mean(x, trim=.1))
- }
- x <- rcauchy(10)
- centre(x, "mean")
- centre(x, "median")
- centre(x, "trimmed")
-
-