Sys.getenv               package:base               R Documentation

_G_e_t _E_n_v_i_r_o_n_m_e_n_t _V_a_r_i_a_b_l_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     'Sys.getenv' obtains the values of the environment variables.

_U_s_a_g_e:

     Sys.getenv(x = NULL, unset = "")

_A_r_g_u_m_e_n_t_s:

       x: a character vector, or 'NULL'.

   unset: a character string.

_D_e_t_a_i_l_s:

     Both arguments will be coerced to character if necessary.

     Setting 'unset = NA' will enable unset variables and those set to
     the value '""' to be distinguished, _if the OS does_.

_V_a_l_u_e:

     A vector of the same length as 'x', with the variable names as its
     'names' attribute.  Each element holds the value of the
     environment variable named by the corresponding component of 'x'
     (or the value of 'unset' if no environment variable with that name
     was found).

     On most platforms 'Sys.getenv()' will return a named vector giving
     the values of all the environment variables, sorted in the current
     locale.  It may be confused by names containing '=' which some
     platforms allow but POSIX does not.

_S_e_e _A_l_s_o:

     'Sys.setenv', 'Sys.getlocale' for the locale in use, 'getwd' for
     the working directory.

     The help for 'environment variables' lists many of the environment
     variables used by R.

_E_x_a_m_p_l_e_s:

     ## whether HOST is set will be shell-dependent e.g. Solaris' csh does not.
     Sys.getenv(c("R_HOME", "R_PAPERSIZE", "R_PRINTCMD", "HOST"))

     names(s <- Sys.getenv()) # all settings (the values could be very long)

     ## Language and Locale settings -- but rather use Sys.getlocale()
     s[grep("^L(C|ANG)", names(s))]

