[Rd] read.table, read.fwf, and na.strings (PR#7075)

rmh at temple.edu rmh at temple.edu
Sat Jul 10 23:21:10 CEST 2004


# Your mailer is set to "none" (default on Windows),
# hence we cannot send the bug report directly from R.
# Please copy the bug report (after finishing it) to
# your favorite email program and send it to
#
#       r-bugs at r-project.org
#
######################################################


Is this intended behavior for the read.fwf(na.strings="-999")?
I anticipated that the na.strings would be padded with blanks.
Therefore I anticipated getting the result tmp2 from the simpler
na.strings in the tmp1 assignment?  My anticipation is based on the
documentation that says
"Blank fields are also considered to be missing values."

> na.strings: a vector of strings which are to be interpreted as 'NA'
>           values.  Blank fields are also considered to be missing
>           values.


temp.dat
----------------
123456-999 01234
56-9990123412345
----------------

read.fwf.test.r
------------------------------------------------
tmp1 <- read.fwf("temp.dat",
                 na.strings="-999",
                 col.names=LETTERS[1:4],
                 widths=c(2,4,5,5))
tmp1
tmp2 <- read.fwf("temp.dat",
                 na.strings=c("-999","-999 "),
                 col.names=LETTERS[1:4],
                 widths=c(2,4,5,5))
tmp2
------------------------------------------------


> tmp1
   A    B    C     D
1 12 3456 -999  1234
2 56   NA 1234 12345
> tmp2
   A    B    C     D
1 12 3456   NA  1234
2 56   NA 1234 12345


--please do not edit the information below--

Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status = 
 major = 1
 minor = 9.1
 year = 2004
 month = 06
 day = 21
 language = R

Windows XP Home Edition (build 2600) Service Pack 1.0

Search Path:
 .GlobalEnv, file:c:/HOME/rmh/hh/splus.library/HH/.RData, package:methods, package:stats, 
package:utils, package:multcomp, package:mvtnorm, package:abind, package:graphics, 
package:lattice, package:grid, Autoloads, package:base



More information about the R-devel mailing list