$sudo apt-get install r-cran-rodbc
$sudo apt-get install unixodbc-dev
好的,RODBC在Ubuntu机器上正确安装.但是当我尝试运行以下脚本时:
## import excel file from DropBox require("RODBC") channel <- odbcConnectExcel("~/DropBox/DATA/SAMPLE/petro.xls") petro <- sqlFetch (channel,"weekly") odbcClose(channel) str(petro) head(petro)
我收到一个错误抛出函数odbcConnectExcel未找到.我检查了每个字母的情况,确保它不是一个简单的拼写错误.不.然后我在Windows R安装上运行相同的脚本(文件路径当然不同),脚本可以工作.
知道为什么Ubuntu R安装无法找到odbcConnectExcel函数以及如何让它工作?
作为参考,从R Data Import / Export manual(我突出显示):
4.3.2 Package RODBC
Package RODBC on CRAN provides an
interface to database sources
supporting an ODBC interface. This is
very widely available,and allows the
same R code to access different
database systems. RODBC runs on
Unix/Linux,Windows and Mac OS X,and
almost all database systems provide
support for ODBC. We have tested
Microsoft sql Server,Access,MysqL,
Postgresql,Oracle and IBM DB2 on
Windows and MysqL,Oracle,Postgresql
and sqlite on Linux.ODBC is a client-server system,and we
have happily connected to a DBMS
running on a Unix server from a
Windows client,and vice versa.On Windows ODBC support is normally
installed,and current versions are
available from
07001 as
part of MDAC. On Unix/Linux you will
need an ODBC Driver Manager such as
unixODBC (07002) or
iOBDC (07003: this is
pre-installed in Mac OS X) and an
installed driver for your database
system.Windows provides drivers not just for
DBMSs but also for Excel (.xls)
spreadsheets, DBase (.dbf) files and
even text files. (The named
applications do not need to be
installed. Which file formats are
supported depends on the the versions
of the drivers.) There are versions
for Excel 2007 and Access 2007 (go to
07004,and
search forOffice ODBC
,which will lead to AccessDatabaseEngine.exe),the `2007 Office System Driver’.