Re: [R] Reading characters using read.table()

About this list Date view Thread view Subject view Author view Attachment view

From: ripley@stats.ox.ac.uk
Date: Wed 07 Aug 2002 - 20:28:24 EST


Message-id: <Pine.LNX.4.31.0208071126520.9202-100000@gannet.stats>

On Wed, 7 Aug 2002, Florent BATY wrote:

> I need to read a vector containing names of different variables from a
> text file (a unique column). Among them one is called "T". When I use
> the function read.table with default arguments and when I call the
> element of the data frame corresponding to name of this variable it
> returns me the logical value "TRUE" whereas I was expected it to return
> the character "T".
> Is it possible to specify the type data expected in a data frame when
> using the read.table function in order to make it unable to interpret
> "T" as "True" ?? Or is there any other functions enabling to import text
> data from a text file ??

Yes, see the help page and argument colClasses.

Yes, I would have used scan().

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jun 2004 - 09:31:05 EST