Hello, 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 ?? Thanks in advance, Florent _______________________________________ Florent BATY CNRS UMR 5558 Dynamique des Populations Bact?riennes Facult? de M?decine Lyon-Sud 69921 OULLINS, BP 12 FRANCE tel : +33 (0)4 78 86 31 67 fax : +33 (0)4 78 86 31 49 _______________________________________ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 at 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 at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Thanks a lot ! By using > var_read.table("file",colClasses=c("character")) R returns a data.frame with characters in it. Florent ripley at stats.ox.ac.uk wrote:>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(). > >-- _______________________________________ Florent BATY CNRS UMR 5558 Dynamique des Populations Bact?riennes Facult? de M?decine Lyon-Sud 69921 OULLINS, BP 12 FRANCE tel : +33 (0)4 78 86 31 67 fax : +33 (0)4 78 86 31 49 _______________________________________ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Did you try the function 'scan' ? Hopin' it helps, Laurent On Wed, Aug 07, 2002 at 12:17:46PM +0200, Florent BATY wrote:> Hello, > > 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 ?? > > Thanks in advance, > > Florent > > > _______________________________________ > > Florent BATY > CNRS UMR 5558 > Dynamique des Populations Bact?riennes > Facult? de M?decine Lyon-Sud > 69921 OULLINS, BP 12 > FRANCE > tel : +33 (0)4 78 86 31 67 > fax : +33 (0)4 78 86 31 49 > _______________________________________ > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- -------------------------------------------------------------- Laurent Gautier CBS, Building 208, DTU PhD. Student DK-2800 Lyngby,Denmark tel: +45 45 25 24 89 http://www.cbs.dtu.dk/laurent -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._