[R] sqlFetch (RODBC) question

From: Kenn Konstabel <lebatsnok_at_gmail.com>
Date: Thu, 03 Mar 2011 16:55:52 +0200

Dear all,

I've used RODBC a lot to read in files created in MS excel and access but found a strange problem today: a variable in my data file contained both numbers and text; sqlFetch would set text within a row of numbers to NA; but if first 5 or 6 rows would be text then all numbers would be read in as NA.

con<-odbcConnectExcel("xample.xls") #the file is attached or at http://psych.ut.ee/~nek/ajutine/xample.xls sqlFetch(con, "TT$")
# ID_NO Setting_ID
#1 NA NA
#2 1220000 12203
# 3 1220001 12203

Whereas the same file saved as csv reads in correctly as:

# ID_NO Setting_ID
#1 b a
#2 1220000 12203
#3 1220001 12203
#4 1220002 12202
#5 1220003 12202

Can anyone explain why it would behave like this?

#just in case:

> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: i386-pc-mingw32/i386 (32-bit)


[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] RODBC_1.3-2 loaded via a namespace (and not attached): [1] iterators_1.0.3 tools_2.12.1

Thanks in advance,

Kenn Konstabel
Department of Chronic Diseases
National Institute for Health Development Hiiu 42
Tallinn, Estonia

R-help_at_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. Received on Thu 03 Mar 2011 - 15:35:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Mar 2011 - 15:40:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive