【发布时间】:2018-09-06 19:50:26
【问题描述】:
我有一个使用 readr 加载的数据集,其中包含 2341 行、401 列和一些 NAs。我正在尝试创建带有连续变量子选择的散点图矩阵。
这是我使用的一些变量的glimpse:
Observations: 2,341
Variables: 3
$ Height <dbl> 175.2000, 175.0000, 174.7000, 174.0000, 173.0000, ...
$ gender <fct> Male, Male, Male, Male, Male, Male, Male, Male, Male, ...
$ lb_pp <dbl> 55.00000, 50.00000, 40.00000, 56.00000, 60.00000, ...
变量 Height、lb_pp 和 gender 分别有 98、150 和 0 个 NA。
大多数变量表现良好,并正常显示在图中。 ggpairs 当我使用具有 150 个 NA 的变量时会引发警告(下面的警告消息),但我得到的情节没有问题,如下所示:
Warning message:
“Removed 150 rows containing non-finite values (stat_boxplot).”`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Warning message:
“Removed 150 rows containing non-finite values (stat_bin).”Warning message:
“Removed 150 rows containing non-finite values (stat_density).”
但是当我使用另一个变量 height 时,它会因不同的警告消息和搞砸的情节而窒息:
Warning message:
“Removed 98 rows containing non-finite values (stat_count).
”Warning message:
“Computation failed in `stat_count()`:
arguments imply differing number of rows: 392, 400, 1
”Warning message:
“Computation failed in `stat_count()`:
arguments imply differing number of rows: 542, 574, 1
”Warning message:
“Removed 98 rows containing non-finite values (stat_count).”Warning message:
“Computation failed in `stat_count()`:
arguments imply differing number of rows: 392, 400, 1”
我可以通过为麻烦的变量过滤掉具有 NA 的行来解决此问题,但是为什么我必须对某些 var 而不是其他的?当我询问is.numeric 时,这两个变量都返回TRUE。有什么区别?
感谢您的帮助。
【问题讨论】:
-
请您使用您的数据子集或一些模拟数据制作一个可重现的示例。