write.table               package:base               R Documentation

_D_a_t_a _O_u_t_p_u_t

_D_e_s_c_r_i_p_t_i_o_n:

     `write.table' prints its required argument `x' (after converting
     it to a data frame if it is not one already) to `file'.  The
     entries in each line (row) are separated by the value of `sep'.

_U_s_a_g_e:

     write.table(x, file = "", append = FALSE, quote = TRUE, sep = " ",
                 eol = "\n", na = "NA", dec = ".", row.names = TRUE,
                 col.names = TRUE, qmethod = c("escape", "double"))

_A_r_g_u_m_e_n_t_s:

       x: the object to be written, typically a data frame.  If not, it
          is attempted to coerce `x' to a data frame.

    file: the name of the file which the data are to be written to.

  append: logical. If true, the output is appended to targshe file. If
          false, any existing file of the name is destroyed.

   quote: a logical or a numeric vector.  If `TRUE', any character or
          factor columns will be surrounded by double quotes.  If a
          numeric vector, its elements are taken as the indices of the
          variable (columns) to quote.  In both cases, row and columns
          names are quoted if they are written, but not if `quote is
          FALSE'.

     sep: the field separator string.  Values within each row of `x'
          are separated by this string.

     eol: the character(s) to print at the end of each line (row).

      na: the string to use for missing values in the data.

     dec: the string to use for decimal points.

row.names: either a logical value indicating whether the row names of
          `x' are to be written along with `x', or a character vector
          of row names to be written.

col.names: either a logical value indicating whether the column names
          of `x' are to be written along with `x', or a character
          vector of column names to be written.

 qmethod: a character string specifying how to deal with embedded
          double quote characters when quoting strings.  Must be one of
          `"escape"' (default), in which case the quote character is
          escaped in C style by a backslash, or `"double"', in which
          case it is doubled.  You can specify just the initial letter.

_D_e_t_a_i_l_s:

     Normally there is no column name for a column of row names If
     `col.names=NA' a blank column name is added. This can be used to
     write CSV files for input to spreadsheets.

_S_e_e _A_l_s_o:

     The `R Data Import/Export' manual.

     `read.table', `write'.

_E_x_a_m_p_l_e_s:

     ## To write a CSV file for input to Excel one might use
     write.table(x, file = "foo.csv", sep = ",", col.names = NA)
     ## and to read this file back into R one needs
     read.table("file.csv", header = TRUE, sep = ",", row.names=1)

