Skip to content
Prev 4849 / 63421 Next

More on scan: extra field at end of line

On Tue, 26 Dec 2000, Peter Kleiweg wrote:

            
You can easily remove the trailing commas, though, as in

scan(pipe("sed -e s/,$// data2"), sep=",")
Read 24 items
 [1] 450 390 467 654  30 542 334 432 421 357 497 493 550 549 467 575 578
342 446
[20] 547 534 495 979 479
However, that's not compatible with S or earlier versions of R or
the documentation 

     sep: by default, scan expects to read white-space delimited input
          fields.  Alternatively, `sep' can be used to specify a
          character which delimits fields.  A field is always delimited
          by a newline unless it is quoted.

I suggest the proper action is to act as documented!