您好,欢迎来到九壹网。
搜索
您的当前位置:首页Rstudio切换运行环境(i386 or x)

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

来源:九壹网

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

R version 3.4.2 (2017-09-28) -- "Short Summer"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_-w-mingw32/x (-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/15427

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务