我使用过之前正在使用的代码(使用其他数据)来可视化新数据。现在,我收到一条错误消息。由于代码与其他数据一起使用,我认为我的新数据与stat_contour()
不喜欢的方式有所不同。
我的代码这一行会产生问题:
stat_contour(aes(z=log_llh),bins=15,colour='black',size=0.5) +
错误消息是:
contourLines中的错误(x = sort(唯一(数据$ x)),y = sort(唯一(数据$ y)),: (list)对象无法强制键入' double' if(nrow(layer_data)== 0)return():参数长度为零
时出错
以下是我的数据片段:
rec,foi,sensit,prev,log_llh,log_llh_prev,log_llh_decay,p_prev,p_decay,p_min
0.50,1.04,1.00,0.67532,-1329.744,-1068.151,-261.593,0.000000,0.000000,0.000000
0.50,1.05,1.00,0.67742,-1335.410,-1073.659,-261.751,0.000000,0.000000,0.000000
0.50,1.06,1.00,0.67949,-1341.070,-1079.136,-261.934,0.000000,0.000000,0.000000
0.50,1.07,1.00,0.68153,-1346.547,-1084.581,-261.967,0.000000,0.000000,0.000000
0.50,1.08,1.00,0.68354,-1352.441,-1089.995,-262.447,0.000000,0.000000,0.000000
0.50,1.09,1.00,0.68553,-1357.835,-1095.377,-262.457,0.000000,0.000000,0.000000
0.50,1.10,1.00,0.68750,-1363.231,-1100.729,-262.501,0.000000,0.000000,0.000000
0.60,0.01,1.00,0.01639,-737.232,-504.203,-233.029,0.000000,0.000000,0.000000
0.60,0.02,1.00,0.03226,-671.471,-438.418,-233.053,0.000000,0.000000,0.000000
0.60,0.03,1.00,0.04762,-639.377,-406.600,-232.777,0.000000,0.000000,0.000000
0.60,0.04,1.00,0.06250,-621.661,-388.539,-233.122,0.000000,0.000000,0.000000
0.60,0.05,1.00,0.07692,-611.319,-377.908,-233.411,0.000012,0.000000,0.000000
0.60,0.06,1.00,0.09091,-605.159,-371.891,-233.268,0.007365,0.000000,0.000000
0.60,0.07,1.00,0.10448,-602.492,-368.991,-233.501,0.239827,0.000000,0.000000
之前有人遇到过这个问题,问题是数据矩阵不遵循常规网格。我的网格有0.1(rec)和0.01(foi)的常规增量。
有没有人知道可能出现的问题?
PS:使用geom_tile(aes(fill=log_llh))
绘制完全相同的数据非常合适,而stat_contour(aes(z=log_llh),bins=15,colour='black',size=0.5)
仍无法正常工作
答案 0 :(得分:1)
用Google搜索并发现:http://www.stat.cmu.edu/~brian/463/hw02/on-making-contour-plots.r 他们说:
无论是什么产生了这个错误,它都没有告诉我们什么地方 该 真正的问题在于......
事实证明问题在于" stat_contour"功能 期望在(x,y)值的常规网格和我们的数据上找到数据 根本不在任何网格上。
因此,您可能需要确保x
和y
为网格。