[R] Mixed mode import problem

Grum, Mikkel M.GRUM at CGIAR.ORG
Thu Aug 9 14:26:56 CEST 2001


First question:
I have an Excel file with both character and numeric variables that I want
to import to a data.frame, so I've saved the data to a tab-delimited text
file.

read.table :
*	Won't identify the mode of my character variables, as some of them
contain only numbers and none of them are surrounded by quotes,
*	Won't allow me to specify the mode of my variables,
*	Doesn't read the whole file, apparently because Excel has added tabs
beyond the end of some rows.

scan:
*	Allows me to specify the mode of my variables,
*	Reads the whole file correctly when I set flush=TRUE,
*	But gives me a list rather than a data.frame,
*	And doesn't allow me to specify row.names and col.names

When I use as.data.frame to convert my file to a data.frame, I lose the mode
of my variables. I tried to protect the mode using I, but if that's the
correct thing to do, I didn't get the syntax right.

Is there any way the I can define the mode of my variables after I have them
in my data frame? Or another solution to my problem.

Second question:
I have a large number of variables, not all of which I'd like to use in all
the analyses.  How do I select just those that I want for the next analysis?

I've worked through R for beginners, the import/export manual, an
introduction to R, and considerable chunks of the reference manual, as well
as a few other texts and I could do with some help.

-mikkel



Mikkel Grum
Genetic Diversity Scientist
International Plant Genetic Resources Institute (IPGRI)
Sub-Saharan Africa Group

m.grum at cgiar.org
ipgri-kenya at cgiar.org
www.ipgri.cgiar.org

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