带数字列的R data.table setkey [英] R data.table setkey with numeric column

查看:29
本文介绍了带数字列的R data.table setkey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在R中使用data.table包.尝试在数字列上使用setkey时,出现以下错误消息:

I'm using the data.table package in R. When trying to use setkey on a numeric column, I'm getting the following error message:

setkey(candidate.SNPs.MAF, p)

Error in setkeyv(x, cols, verbose = verbose) :
Column 'p' cannot be coerced to integer without losing fractional data.

我看到了最近的答案,表明我需要至少具有v1.8.1,并确认使用最新版本(1.8.2)时会出现此问题

I've seen a recent answer that suggests I need to have at least v1.8.1 and have confirmed that this problem occurs when using the newest version (1.8.2)

help(package="data.table")
               Information on package 'data.table'

Description:
Package:            data.table
Version:            1.8.2

有什么建议吗?我宁愿不必恢复到data.frames.

Any suggestions? I'd rather not have to revert to data.frames.

我的数据结构如下:

str(can_SNPs_context)
Classes 'data.table' and 'data.frame':  1031 obs. of  23 variables:
$ Trait            : chr  "GH2_SLA" "GH2_SLA" "GH2_SLA" "GH2_SLA" ...
$ Locus            : chr  "1" "1" "1" "1" ...
$ Marker           : int  1825530 1844004 2251065 2444826 2832616 3557976 4299 650 4606939 4610965 6057450 ...
$ p                : num  8.68e-08 7.21e-08 1.11e-07 1.20e-08 8.17e-08 ...

p列是我要设置为键的列-很小的值会引起问题吗?

The p column is the one I'm trying to set as the key - do the very small values cause the problem?

R版本2.15.1Linux x86_64

R version 2.15.1 Linux x86_64

谢谢!

推荐答案

作为Andrie和mnel,我也无法复制.

As Andrie and mnel, I couldn't replicate either.

要测试您是否安装了 data.table ,请输入:

To test your installation of data.table type :

test.data.table()

在我的上网本上,返回:

On my netbook this returns :

[.. snip ..]
All 717 tests in test.data.table() completed ok in 50.040sec

如果它准确地返回 717 ,那么您就很好.新闻的注释"部分 for 1.8.2是您发现1.8.2具有717个测试的地方.

If it returns precisely 717 then you're good. The NOTES section of NEWS for 1.8.2 is where you find out that 1.8.2 has 717 tests.

是否有可能您升级到1.8.2但没有重新加载程序包,或者在一个升级中有多个R会话在运行,而在其他升级中却没有重新加载? help packageVersion 等报告磁盘上软件包的版本,而不是加载到内存中的版本afaik.加载data.table时,它是启动横幅,告诉您正在运行的版本.

Is it possible you upgraded to 1.8.2 but didn't reload the package, or had several R sessions running when you upgraded in one but didn't reload in the others? help, packageVersion etc report the version of the package on disk, not the version that was loaded into memory, afaik. It's the startup banner when data.table loads that tells you the version running.

我不知道R是否将加载的程序包版本存储到内存中.如果没有,建议建议r-devel,然后更改 packageVersion hep(package =)以检查内存中的版本(如果已加载)与磁盘上的匹配.

I don't know if R stores the version of the package loaded into memory. If it doesn't, that would be good to propose to r-devel, and change packageVersion and hep(package=) to check the version in memory (if loaded) matches that on disk.

这篇关于带数字列的R data.table setkey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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