tempfile                package:base                R Documentation

_C_r_e_a_t_e _N_a_m_e_s _f_o_r _T_e_m_p_o_r_a_r_y _F_i_l_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     'tempfile' returns a vector of character strings which can be used
     as names for temporary files.

_U_s_a_g_e:

     tempfile(pattern = "file", tmpdir = tempdir())
     tempdir()

_A_r_g_u_m_e_n_t_s:

 pattern: a non-empty character vector giving the initial part of the
          name.

  tmpdir: a non-empty character vector giving the directory name

_D_e_t_a_i_l_s:

     If 'pattern' has length greater than one then the result is of the
     same length giving a temporary file name for each component of
     'pattern'.

     The names are very likely to be unique among calls to 'tempfile'
     in an R session and across simultaneous R sessions.  The filenames
     are guaranteed not to be currently in use.

     The file name is made of the pattern and a random suffix in hex. 
     By default, the filenames will be in the directory given by
     'tempdir()'.  This will be a subdirectory of the temporary
     directory found by the following rule.  The environment variables
     'TMPDIR', 'TMP' and 'TEMP' are checked in turn and the first found
     which points to a writable directory is used: if none succeeds
     '/tmp' is used.

_V_a_l_u_e:

     For 'tempfile' a character vector giving the names of possible
     (temporary) files. Note that no files are generated by 'tempfile'.

     For 'tempdir', the path of the per-session temporary directory.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'unlink' for deleting files.

_E_x_a_m_p_l_e_s:

     tempfile(c("ab", "a b c"))   # give file name with spaces in!

     tempdir() # working on all platforms with quite platform dependent result

