write.dbf              package:foreign              R Documentation

_W_r_i_t_e _a _D_B_F _F_i_l_e

_D_e_s_c_r_i_p_t_i_o_n:

     The function tries to write a data frame to a DBF file.

_U_s_a_g_e:

     write.dbf(dataframe, file, factor2char = TRUE)

_A_r_g_u_m_e_n_t_s:

dataframe: a data frame object.

    file: a file name to be written to.

factor2char: logical, default 'TRUE', convert factor columns to
          character: otherwise they are written as the internal integer
          codes.

_D_e_t_a_i_l_s:

     Dots in column names are replaced by underlines in the DBF file,
     and names are truncated to 11 characters.

     Only vector columns of classes '"logical"', '"numeric"',
     '"integer"', '"character"', '"factor"' and '"Date"' can be
     written.  Other columns should be converted to one of these.

     Maximum precision (number of digits including minus sign and
     decimal sign) for numeric is 19 - scale (digits after the decimal
     sign) which is calculated internally based on the number of digits
     before the decimal sign.

_V_a_l_u_e:

     Invisible 'NULL'.

_N_o_t_e:

     Other applications have varying abilities to read the data types
     used here.  Microsoft Access read '"numeric"', '"integer"',
     '"character"' and '"Date"' fields, including recognizing missing
     values, but not '"logical"' (read as '0,-1'). Microsoft Excel
     understood all possible types but did not interpret missing values
     in character fields correctly (showing them as character nuls).

_A_u_t_h_o_r(_s):

     Nicholas J. Lewin-Koh, modified by Roger Bivand and Brian Ripley;
     shapelib by Frank Warmerdam.

_R_e_f_e_r_e_n_c_e_s:

     <URL: http://shapelib.maptools.org/>

_S_e_e _A_l_s_o:

     'read.dbf'

_E_x_a_m_p_l_e_s:

     str(warpbreaks)
     try1 <- paste(tempfile(), ".dbf", sep = "")
     write.dbf(warpbreaks, try1, factor2char = FALSE)
     in1 <- read.dbf(try1)
     str(in1)
     try2 <- paste(tempfile(), ".dbf", sep = "")
     write.dbf(warpbreaks, try2, factor2char = TRUE)
     in2 <- read.dbf(try2)
     str(in2)
     unlink(c(try1, try2))

