[R] Problem with table

John Fox jfox at mcmaster.ca
Fri May 3 18:24:16 CEST 2002


Dear Ale,

At 03:02 PM 5/3/2002 +0200, Ambrosini Alessandro wrote:
>I have to import this table
>
>aa bb cc vic
>bb cif aa dd ee
>
>Using "read.table" I want to obtain
>
>   V1 V2  V3 V4  V5
>1 aa bb  cc vic
>2 bb cif aa dd  ee
>
>but writing read.table("dat.txt",fill=TRUE) it gives me
>
>     aa bb cc vic
>bb cif aa dd  ee
>
>and so it considers that the first column and the first row are the names of
>columns and rows but it is not true because I want to consider everything as
>data.
>What have I to add into read.table?

The problem here is that the first row of the data file has one fewer entry 
(4) than the second row (5), so read.table assumes that the first row 
contains column names. You could try setting header=FALSE in the call to 
read.table, but that will generate an error, since the numbers of entries 
in the lines differ.

Why not just fill out the first line in the file with NA?

     aa bb cc vic NA
     bb cif aa dd ee

John


-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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