1

尝试绘制我的数据时,我收到以下错误消息:

1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

这个可重现的代码有效:

# some dummy data
library(mvtnorm)
dat <- rmvnorm(10000, mean=c(x=4,y=4), sigma=matrix(c(1,0.5,0.5,1), ncol=2))
dat <- as.data.frame(dat)

# 2d density plot
library(MASS)
kdexy <- kde2d(dat$x,dat$y, n=50)
image(kdexy, col=grey(seq(1,0.2,length=10)))

但是使用我的真实数据不会:

kdexy <- kde2d(temp$V1, temp$V2, n=50)
image(kdexy, col=grey(seq(1,0.2,length=10)))

然而,这两个数据集的结构是相同的(虚拟数据 [dat] 和真实数据 [temp]):

> str(dat$x)
 num [1:80000] 0.669 0.609 -0.633 0.565 0.559 ...
> str(temp$V1)
 num [1:823180] 0 0 0 0 0.0146 ...
> summary(dat$x)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-4.2270 -0.1902  0.4841  0.4900  1.1600  5.3570 
> summary(temp$V1)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-1.0000  0.0000  0.0000 -0.0289  0.0000  0.9844 
> range(dat$x)
[1] -4.227400  5.357184
> range(temp$V1)
[1] -1.000000  0.984375
> str(temp$V2)
 num [1:823180] 1 1 15.5 15.5 18.5 ...
> summary(temp$V2)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1.00    1.00   18.45   23.55   35.96  116.10 
> range(temp$V2)
[1]   1.0000 116.0829

它们都存储在数据帧中,我知道的唯一区别是长度,它以andtemp$V1为界。-11

两个数据集的输出kdexy <- kde2d()不同。在示例数据中,这些Z部分填充了非常小的数字;在真实数据集中,每个点都填充了“NaN”。

4

1 回答 1

1

我的数据高度集中在 0 ( total n=850,000, n==0 ~ 650,000) 附近。使用数据子集,其中x<0( n=150,000),绘图有效。

于 2012-07-27T11:35:09.030 回答