R 使用ggplot2热图直观显示每列中的NAs数量

R 使用ggplot2热图直观显示每列中的NAs数量,r,ggplot2,R,Ggplot2,我有一个向量,它包含数据集每列中的NAs数量 countNA <- c(0, 0, 88, 88, 161, 84, 540, 0, 84, 84, 84, 86, 101, 77, 80, 80, 72, 119, 72, 0, 72, 86, 72, 70, 70, 70, 161, 86, 80, 101, 77, 497, 80, 161, 88, 84, 86, 497, 471, 81, 560, 88, 88, 497, 472, 84, 0) countNA这里有一个可

我有一个向量,它包含数据集每列中的NAs数量

countNA <-  c(0, 0, 88, 88, 161, 84, 540, 0, 84, 84, 84, 86, 101, 77, 80, 80, 72, 119, 72, 0, 72, 86, 72, 70, 70, 70, 161, 86, 80, 101, 77, 497, 80, 161, 88, 84, 86, 497, 471, 81, 560, 88, 88, 497, 472, 84, 0)

countNA这里有一个可能的解决方案:

ggplot(data = plotNA3, aes(x=VariableNames, y=team, fill=countNA)) +
  geom_tile() +
  labs(fill='Number of NAs in each column')+
  geom_text(aes(label=paste(sprintf("%.1d", countNA))), size=2, color="white")+
  theme(aspect.ratio=1/25)

有助于此
几何平铺(高度=0.1)
?此选项仅缩放主层内的平铺。我想所有的情节是“规模”,但我找不到如何去看看包。它的功能设计为可以轻松地查找数据集中每个列的缺失数据,并且它构建在ggplotOk之上,那么这是什么呢<代码>主题(legend.position=“top”,.plot.margin=margin(0,1,1,1,1,“cm”)
看不到任何真正的区别,但我会玩弄一些变量
ggplot(data = plotNA3, aes(x=VariableNames, y=team, fill=countNA)) +
  geom_tile() +
  labs(fill='Number of NAs in each column')+
  geom_text(aes(label=paste(sprintf("%.1d", countNA))), size=2, color="white")+
  theme(aspect.ratio=1/25)