Rstudio切换运行环境(i386 or x64)

R语言在编程过程中,遇到一个问题,在使用RODBC过程中提示和报错信息:

R version 3.4.2 (2017-09-28) -- "Short Summer"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Workspace loaded from ~/.RData]

> library(RODBC)
> XlsChannel <- odbcConnectExcel("test.xlsx")
Error in odbcConnectExcel("test.xlsx") : 
  odbcConnectExcel is only usable with 32-bit Windows
> 

类似问题可能需要我们切换R语言运行环境,下面介绍Rstudio切换运行环境。

首先打开Rstudio,找到工具(options)选项。如下图所示。 输入图片说明

找到Global Options,如下图所示。

输入图片说明

在General选项中找到R version,不需要切换标签,如下图所示。

输入图片说明

重新启动编辑器Rstudio即可,错误一般可以消失。

下面介绍所遇到第二个问题。

> library(RODBC)
> channel<-odbcConnectExcel("test.xlsx")
Warning messages:
1: In odbcDriverConnect(con, tabQuote = c("[", "]"), ...) :
  [RODBC] ERROR: state 42000, code -1809, message [Microsoft][ODBC Excel 驱动程序] 不能更新。数据库或对象为只读。
2: In odbcDriverConnect(con, tabQuote = c("[", "]"), ...) :
  ODBC connection failed

先尝试文件指定绝对路径。

> channel<-odbcConnectExcel("C:\\Documents\\R\\test.xlsx")
Warning messages:
1: In odbcDriverConnect(con, tabQuote = c("[", "]"), ...) :
  [RODBC] ERROR: state HY000, code -5015, message [Microsoft][ODBC Excel 驱动程序] 外部表不是预期的格式。
2: In odbcDriverConnect(con, tabQuote = c("[", "]"), ...) :
  ODBC connection failed

仔细检查代码,发现问题所在,修改后代码如下:

channel<- odbcConnectExcel2007("C:\\Documents\\R\\test.xlsx")

转载于:https://my.oschina.net/u/1011130/blog/1548927

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值