[R] read.table and missing values

Ragnar Beer rbeer at uni-goettingen.de
Tue Jun 19 18:25:45 CEST 2001


<snip>
>You have set sep="\t", haven't you?  The default separator is white space,
>and that will swallow two tabs.  The following had tabs in originally,
>
>a	b	c
>1	2	3
>4		6
>	8	9
>
>and gives
>
>>  read.table("foo.dat", header=T, sep="\t")
>    a  b c
>1  1  2 3
>2  4 NA 6
>3 NA  8 9
<snip>

Cool! Thanks a lot! I had the same problem a while ago and solved it
by replacing two consecutive tabs with \t""\t. Now I see what the
problem was: When I'm not using R I'm using StatView and StatView
defaults to the tab as separator. (I don't remember what it was in
SPSS or Systat.) So I assumed that it's the same with R.
I didn't notice the sep = "" in the Usage section of the help page.
To make the default value more visible in this case it would be
nice if in the Arguments/sep section for read.table it would read
... If sep = "" (the default) the separator is ...
                 -------------

Cheers,

Ragnar

(Must've said "blimey" once too often -
  now I'm really blind every now and then ;)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list