如何在 R 中加载包 [英] How to load packages in R

查看:75
本文介绍了如何在 R 中加载包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功安装了 tm 包,它位于:C:\Users\JustinLiang\Documents\R\win-library\3.0

I have successfully installed the tm package, which is located in: C:\Users\JustinLiang\Documents\R\win-library\3.0

输入 library() 后,它会显示可用的 R 包列表:

After type library(), it shows me the R packages available list:

库‘C:/Users/JustinLiang/Documents/R/win-library/3.0’中的包:

Packages in library ‘C:/Users/JustinLiang/Documents/R/win-library/3.0’:

tm 文本挖掘包

库‘C:/Program Files/R/R-3.0.2/library’中的包:

Packages in library ‘C:/Program Files/R/R-3.0.2/library’:

但是,当我尝试加载包:library(tm) 时,它显示了一个错误:

however, when I try to load the package: library(tm), it shows me an error:

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called ‘slam’
Error: package or namespace load failed for ‘tm’

推荐答案

在使用 library() 加载包之前,必须先安装包.要安装任何软件包,请打开 RRStudio shell 并执行以下操作

The package has to be first installed before you load the package using library(). To install any package, open the R or RStudio shell and execute the following

install.packages("tm",dependencies=TRUE)

这将要求您选择镜像并为您安装它.如果您使用 RStudio,您可以从 Tools 菜单中轻松完成,如下所示(Tools -> Install Packages -> 您要安装的软件包的名称).

This will ask you to select the mirror and it will install it for you. If you use RStudio, you can easily do it from the Tools menu as shown below (Tools -> Install Packages -> Name of the package you want to install).

最后,您可以调用library("安装包的名称") 函数.

And then finally, you can invoke the library("name of the package installed") function.

这篇关于如何在 R 中加载包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆