home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Educational / R-0.49-MI / R-0.49-I / help / base / write < prev    next >
Encoding:
Text File  |  1997-04-23  |  1023 b   |  38 lines

  1.     
  2.     _W_r_i_t_e _d_a_t_a _t_o _a _f_i_l_e
  3.     
  4.          write(x, file="data",
  5.                  ncolumns=if(is.character(x)) 1 else 5,
  6.                  append=FALSE)
  7.     
  8.     _A_r_g_u_m_e_n_t_s:
  9.     
  10.                x : the data to be written out.
  11.     
  12.             file : the name of the file (quoted) to write to.
  13.     
  14.         ncolumns : the number of columns to write the data in.
  15.     
  16.           append : if TRUE the data x is appended to file file.
  17.     
  18.     _D_e_s_c_r_i_p_t_i_o_n:
  19.     
  20.          The data (usually a matrix) x are written to file file.
  21.          If x is a two dimensional matrix you need to transpose
  22.          it to get the columns in file the same as those in the
  23.          internal representation.
  24.     
  25.     _E_x_a_m_p_l_e_s:
  26.     
  27.          # create a 2 by 5 matrix
  28.          x <- matrix(1:10,ncol=5)
  29.     
  30.          # the file data contains x, two rows, five cols
  31.          # 1 3 5 6 9 will form the first row
  32.          write(t(x))
  33.     
  34.          # the file data now contains the data in x,
  35.          # two rows, five cols but the first row is 1 2 3 4 5
  36.          write(x)
  37.     
  38.