如何使用 R 读取 .arff 文件?
有什么办法可以做到这一点吗?
是的,我是 R 新手。
Is there any way to do that?
Yes, i'm new to R.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有什么办法可以做到这一点吗?
是的,我是 R 新手。
Is there any way to do that?
Yes, i'm new to R.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
foreign
包中的read.arff
从 Weka 属性关系文件格式 (ARFF) 文件读取数据。更新:CRAN 上有一个新软件包:
farff:更快的“ARFF”文件读取器和写入器
read.arff
in packageforeign
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
一般来说,此类问题的答案可以通过
sos
包找到,该包可以访问 CRAN 上所有包的全文搜索。查找
foreign
(如上所述)和RWeka
包中的函数。由于foreign
是推荐的软件包,因此默认情况下它将安装在您的系统上。 找到答案因此,您应该首先 ,而无需安装
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.finds functions in the
foreign
(as noted above) andRWeka
packages. Sinceforeign
is a recommended package, it will be installed on your system by default. Hence you would have found the answer within 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 thathelp.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 inforeign
(which you should try first) fails for some reason.尽管这个问题已经得到解答,但我意识到还有另一个值得注意的解决方案。检查 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 writearff
files. Plus it gives you a wrapper forWeka
functions. So you could use Weka functionality without installing Weka itself (though it installs .jars). See also this doku ->read.arff
.如果您只关心数据而不关心关系,您可以使用:
If you only care about the data and not the relations, you can just use:
最简单的方法是使用
"RWeka"
库,该库具有读取.arff
文件的read.arff()
函数。希望这有帮助。
The easiest way to do it is using the
"RWeka"
library which hasread.arff()
function that reads.arff
files.Hope this helps.