On Apr 4, 2011, at 6:05 PM, Folkes, Michael wrote:

I'm using RODBC to read an excel file (not mine!). But I'm struggling to find a way to preserve the column names that have a numeric value. sqlFetch() drops the value and calls them f1, f2, f3,... (ie field number). this is a different approach from read.csv, which will append "V" prior to the numeric column name.

read.table() (and perhaps read.csv) has a check.names argument which defaults to TRUE but can be set to FALSE. You will then need to take special care with the result, since those are not "safe" column names.

Another way would be to read only one line in with readLines and then assign to names(dfrm) which would be read in with `skip` = 1.


 sqlFetch isn't so helpful.

Is there a way to get the first line of data from the excel file and place it in a vector? Perhaps I can use that method and rename the dataframe column names later?

thanks!
Michael

--

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to