找回密码
 注册
查看: 4664|回复: 6

使用一个包的安装和使用

[复制链接]
发表于 2012-4-4 09:50:04 | 显示全部楼层 |阅读模式
     请教各位,我从http://cran.r-project.org/web/packages/RMySQL/index.html 下了一个RMySQL的包,本地安装却总是出错,这是为什么呢?是不是还要安装别的包?有没有朋友用过这个包?  
回复

使用道具 举报

发表于 2012-4-4 10:15:35 | 显示全部楼层
啥系统,liunix还是windows
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-4-4 10:34:54 | 显示全部楼层
redcat 发表于 2012-4-4 10:15
啥系统,liunix还是windows

我用的是win7
回复 支持 反对

使用道具 举报

发表于 2012-4-4 13:21:49 | 显示全部楼层
用这个按报错吗
install.packages('RMySQL',type='source')
回复 支持 反对

使用道具 举报

发表于 2012-4-4 13:23:22 | 显示全部楼层
下面的内容在网上看到的,不知道能不能帮到你


Installing the RMySQL package on Windows 7

Tags: r, rmysql, windows


Oct 25 2011 10:50 PM

So you want to get statistical? Nowadays one of the ways to go is to use R, mostly in combination with ggplot2 for generating the plots. These plots and graphs however need some data, for that we use data sources. There are a lot of data sources available for us to use and every company and consumer has its own opinion about which one to use, which can even differ per type of usage, application or website. Therefore a lot of database adapters exist for R; one of these adapters is RMySQL, packaged as the RMySQL package.

This post describes the installation of the RMySQL package from beginning to end, assuming you have a 32-bit Windows 7 machine ready.

MySQL

First off we need a working MySQL installation. Head over to http://www.mysql.com/ and download the server of your wishes  Or use, like me, mysql-5.5.17-win32.msi. Follow it's installation instructions and make sure the checkbox next to "Client tools" is checked. I installed it to "C:\Program Files\MySQL\MySQL Server 5.5\", and when you don't, remember to change each of MySQL's paths following. After the installation press the "Windows" key and enter "System", this will open your system's settings screen. Click on "Advanced settings" and choose Environment Variables. When the screen pops up, add a new environment variable for all users and name it "MYSQL_HOME" with a value of "C:\Program Files\MySQL\MySQL Server 5.5\.

This is not all yet! Create the directory "opt" within "C:\Program Files\MySQL\MySQL Server 5.5\lib" and copy-paste "C:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.lib" to "C:\Program Files\MySQL\MySQL Server 5.5\lib\opt\" and "C:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.dll" to "C:\Program Files\R\R-2.13.2\bin\i386\".

R

After the installation of MySQL it's time to install R from http://cran.r-project.org/bin/windows/base/, the version I use is 2.13.2. Again follow the installation instructions, choosing for a "Full installation" and a customized startup at the "Startup options" screen to setup your preferred way of display, for me that was: "MDI", "HTML help" and "Internet2" while having "C:\Program Files\R\R-2.13.2" chosen as installation directory.



Now, that was easy, we already installed MySQL and R, what's next?



RTools

For the more difficult part of this post we go to http://www.murdoch-sutherland.com/Rtools/ and install the Rtools for R 2.13.x, i.e. Rtools213.exe, this allows us to build packages for R under Windows. Note that there are other packages and tools available for doing this but in my experience this was the most easy one, so we stick with this one for now.

Install Rtools to "c:\Rtools" and go for a "Custom installation" by checking "Extras to build 32 bit R: TCL/TK, bitmap code, internationalization" and at the "Select R Source Home Directory", paste "C:\Program Files\R\R-2.13.2\src" in the textfield. Click on "Next >" and choose to "Edit the system PATH" by ticking the checkbox to the left of it. The rest speaks for itself.

Rcmd.bat

Download this from http://code.google.com/p/batchfiles/source/browse/trunk/Rcmd.bat into "C:\Program Files\R\R-2.13.2\bin".

RStudio

One application very useful to have, though not necessary is RStudio, downloaded from http://rstudio.org/. With this application we have direct access to the R command line tools, a plots window and more. I recommend downloading this application not only for the purpose of this tutorial but also for upcoming daily(?) usage.

Make sure you download "RStudio 0.94.110 - Windows XP/Vista/7" and choose "C:\Program Files\RStudio" as its installation directory.

RMySQL

Now hit the Windows key and enter "RStudio", and when the program "RStudio" comes up, click it. At the console window type
install.packages('RMySQL',type='source')
and hit Enter. Choose the country most close to you as CRAN mirror for the fastest download, mine is 47.
Note: When the message:

"Warning in install.packages :

  'lib = "C:/Program Files/R/R-2.13.2/library"' is not writable"

shows up, head over to the directory and grant modification rights to the current user (or the RStudio user when installed under its own user profile) and execute the install.packages('RMySQL',type='source') command again.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-4-4 16:40:51 | 显示全部楼层
redcat 发表于 2012-4-4 13:21
用这个按报错吗
install.packages('RMySQL',type='source')

谢谢你。用这个还是不行,这个报错的信息不知道什么意思

> install.packages('RMySQL',type='source');
试开URL’http://ftp.ctex.org/mirrors/CRAN/src/contrib/RMySQL_0.9-3.tar.gz'
Content type 'application/x-gzip' length 165363 bytes (161 Kb)
打开了URL
downloaded 161 Kb

* installing *source* package 'RMySQL' ...
** 成功将'RMySQL'程序包解包并MD5和检查
ERROR: configuration failed for package 'RMySQL'
* removing 'D:/R-2.14.2/library/RMySQL'

下载的程序包在
        ‘C:\Users\acer\AppData\Local\Temp\RtmpuUlzJK\downloaded_packages’里
警告信息:
1: 运行命令'D:/R-2.14.2/bin/i386/R CMD INSTALL -l "D:/R-2.14.2/library"   C:\Users\acer\AppData\Local\Temp\RtmpuUlzJK/downloaded_packages/RMySQL_0.9-3.tar.gz'的状态是1
2: In install.packages("RMySQL", type = "source") :
  安装程序包‘RMySQL’时退出狀態的值不是0
回复 支持 反对

使用道具 举报

发表于 2012-4-15 22:30:30 | 显示全部楼层
可能需要关联包,你要注意一下……也可以下zip包,直接安装……
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-22 06:54 , Processed in 0.027814 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表