如何使用 R 读取 .arff 文件?

发布于 2024-12-06 13:27:54 字数 41 浏览 1 评论 0原文

有什么办法可以做到这一点吗?

是的,我是 R 新手。

Is there any way to do that?

Yes, i'm new to R.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

有深☉意 2024-12-13 13:27:54

foreign 包中的 read.arff 从 Weka 属性关系文件格式 (ARFF) 文件读取数据。

更新:CRAN 上有一个新软件包:

farff:更快的“ARFF”文件读取器和写入器

read.arff in package foreign reads data from Weka Attribute-Relation File Format (ARFF) files.

Update: there is a new package on CRAN:

farff: A Faster 'ARFF' File Reader and Writer

一身骄傲 2024-12-13 13:27:54

一般来说,此类问题的答案可以通过 sos 包找到,该包可以访问 CRAN 上所有包的全文搜索。

install.packages("sos")
library("sos")
findFn("arff")

查找 foreign (如上所述)和 RWeka 包中的函数。由于 foreign 是推荐的软件包,因此默认情况下它将安装在您的系统上。 找到答案

help.search("arff")

因此,您应该首先 ,而无需安装 sos 软件包。当您要搜索的字符串不在元数据(标题、关键字、别名等)中时,sos 仍然值得使用,这就是 help.search 搜索,或者不在您系统上已安装的软件包中(同上)。 (查看R 数据导入/导出手册,该手册也随您的系统一起提供,通常很有用,但不会找到这个问题的答案...)

了解RWeka版本可能会很有用,因为< code>foreign (您应该首先尝试)由于某种原因失败。

In general the answer to questions like this can be found via the sos package, which accesses a full-text search of all the packages on CRAN.

install.packages("sos")
library("sos")
findFn("arff")

finds functions in the foreign (as noted above) and RWeka packages. Since foreign is a recommended package, it will be installed on your system by default. Hence you would have found the answer with

help.search("arff")

in the first place, without installing the sos package. sos is still worth having for times when the string you are searching for isn't in the metadata (title, keywords, alias, etc.), which is all that help.search searches, or not in a package you already have installed on your system (ditto). (Looking through the R Data Import/Export Manual, which also comes with your system, is generally useful but would not have found the answer to this question ...)

It might be useful to know about the RWeka version on the off chance that the version in foreign (which you should try first) fails for some reason.

澉约 2024-12-13 13:27:54

尽管这个问题已经得到解答,但我意识到还有另一个值得注意的解决方案。检查 RWeka 包,它使您能够读取和写入 arff 文件。另外,它还为您提供了 Weka 函数的包装器。因此,您可以使用 Weka 功能,而无需安装 Weka 本身(尽管它安装了 .jars)。另请参阅此 doku -> 读取.arff

Even though this question is already answered I realize there is another noteworthy solution. Check the RWeka package that enables you to read and write arff files. Plus it gives you a wrapper for Weka functions. So you could use Weka functionality without installing Weka itself (though it installs .jars). See also this doku -> read.arff.

掐死时间 2024-12-13 13:27:54

如果您只关心数据而不关心关系,您可以使用:

read.csv("data.arff", header=FALSE, comment.char = "@")

If you only care about the data and not the relations, you can just use:

read.csv("data.arff", header=FALSE, comment.char = "@")
暮光沉寂 2024-12-13 13:27:54

最简单的方法是使用 "RWeka" 库,该库具有读取 .arff 文件的 read.arff() 函数。

library(RWeka)
test=read.arff("../Test/test.arff")

希望这有帮助。

The easiest way to do it is using the "RWeka" library which has read.arff() function that reads .arff files.

library(RWeka)
test=read.arff("../Test/test.arff")

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文