Hi one col in my Excel file contains many numbers. But on line 3000 and some other lines are strings like "FG 1". "RODBS" seems to omit this lines. "gdata" works, but is much slower. Is this a bug of RODBC or do I apply it wrong? Example with the same "file.xlsx" library(RODBC); excel <- odbcConnectExcel2007("file.xlsx") tab <- sqlQuery(excel, 'select * from "Table 1$"'); str(tab) col1: num 1 2 3 4 5 6 7 8 9 10 ... library(gdata); tab <- read.xls("file.xlsx", sheet=1); str(tab) col1: Factor w/ 51 levels "1","10","11",..: 1 12 23 34 41 42 43... greeting Christof
Hi Christof, have a look at the manual of RODBC, and in particular the section on Excel drivers. RShowDoc("RODBC", package="RODBC") Regards, Enrico Am 09.01.2012 19:02, schrieb Christof Klu?:> Hi > > one col in my Excel file contains many numbers. But on line 3000 and > some other lines are strings like "FG 1". "RODBS" seems to omit this > lines. "gdata" works, but is much slower. > > Is this a bug of RODBC or do I apply it wrong? > > Example with the same "file.xlsx" > > > library(RODBC); excel<- odbcConnectExcel2007("file.xlsx") > tab<- sqlQuery(excel, 'select * from "Table 1$"'); str(tab) > > col1: num 1 2 3 4 5 6 7 8 9 10 ... > > library(gdata); tab<- read.xls("file.xlsx", sheet=1); str(tab) > > col1: Factor w/ 51 levels "1","10","11",..: 1 12 23 34 41 42 43... > > > greeting > Christof > > ______________________________________________ > 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. >-- Enrico Schumann Lucerne, Switzerland http://nmof.net/
On Mon, Jan 9, 2012 at 1:02 PM, Christof Klu? <ckluss at email.uni-kiel.de> wrote:> Hi > > one col in my Excel file contains many numbers. But on line 3000 and > some other lines are strings like "FG 1". "RODBS" seems to omit this > lines. "gdata" works, but is much slower. > > Is this a bug of RODBC or do I apply it wrong? > > Example with the same "file.xlsx" > > > library(RODBC); excel <- odbcConnectExcel2007("file.xlsx") > tab <- sqlQuery(excel, 'select * from "Table 1$"'); str(tab) > > col1: num ?1 2 3 4 5 6 7 8 9 10 ... > > library(gdata); tab <- read.xls("file.xlsx", sheet=1); str(tab) > > col1: Factor w/ 51 levels "1","10","11",..: 1 12 23 34 41 42 43...You might be able to speed up read.xls in gdata. Try turning off comment characters and setting colClasses, e.g. DF <- read.xls(...whatever..., comment.char = "", colClasses = ...whatever...) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com