read.fwf                package:base                R Documentation

_R_e_a_d _F_i_x_e_d _W_i_d_t_h _F_o_r_m_a_t _F_i_l_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Read a ``table'' of fixed width formatted data into a
     `data.frame'.

_U_s_a_g_e:

     read.fwf(file, widths, sep="\t", as.is = FALSE,
              skip = 0, row.names, col.names)

_A_r_g_u_m_e_n_t_s:

    file: the name of the file which the data are to be read from. Each
          row of the table appears as one line of the file.

  widths: integer vector, giving the widths of the fixed-width fields
          (of one line).

     sep: character; the separator used internally; should be a
          character that does not occur in the file.

   as.is: see `read.table'.

    skip: number of initial lines to skip; see `read.table'.

row.names: see `read.table'.

col.names: see `read.table'.

_D_e_t_a_i_l_s:

     Fields that are of zero-width or are wholly beyond the end of the
     line in `file' are replaced by `NA'.

_V_a_l_u_e:

     A `data.frame' as produced by `read.table' which is called
     internally.

_A_u_t_h_o_r(_s):

     Brian Ripley for R version: original `Perl' by Kurt Hornik.

_S_e_e _A_l_s_o:

     `scan' and `read.table'.

_E_x_a_m_p_l_e_s:

     ff <- tempfile()
     cat(file=ff, "123456", "987654", sep="\n")
     read.fwf(ff, width=c(1,2,3))    #> 1 23 456 \ 9 87 654
     unlink(ff)
     cat(file=ff, "123", "987654", sep="\n")
     read.fwf(ff, width=c(1,0, 2,3))    #> 1 NA 23 NA \ 9 NA 87 654
     unlink(ff)

