RINNER Heinrich
2010-Oct-13 12:59 UTC
[R] RODBC: forcing a special column to be read in as character
Dear R-users, I am working with R version 2.10.1 and package RODBC Version: 1.3-2 under windows. Say I have a table "testtable" (in an Access data base), which has many different columns, among them a character column "X" with "integer-like" data as "0012345". Using sqlFetch, I'd like to assure that column X is read in as a character variable. So what I'm looking for is something between these two approaches:> sqlFetch(channel, "testtable") # -> column X is automatically converted to character (so 0012345 becomes 12345) > sqlFetch(channel, "testtable", as.is = TRUE) # -> all columns are converted to characterI guess I'm looking for something like argument "colClasses" in function "read.table", is there a something similar in RODBC? Your advice is appreciated; kind regards Heinrich.
Jack T.
2011-May-03 17:28 UTC
[R] RODBC: forcing a special column to be read in as character
I've had the same problem and ended up using the xlsReadWrite package. It takes more time to import a sheet but does have the colClasses command. Following your example: library(xlsReadWrite) read.xls("testtable", sheet = "sheet1", colClasses="character") should worked, it did for me -- View this message in context: http://r.789695.n4.nabble.com/RODBC-forcing-a-special-column-to-be-read-in-as-character-tp2993624p3493081.html Sent from the R help mailing list archive at Nabble.com.