R计数x

时间:2019-10-23 01:05:55

标签: r

我正在尝试为数据集的每一列计算NA值,我能够获取此信息,但是现在我试图对其进行汇总,然后将信息放入数据框中。

数据集(细分)-

enter image description here

data_matrix = as.data.frame(matrix(0,nrow = 4, ncol=2))
colnames(data_matrix) = c("Number missing","Frequency")
data_matrix$`Number missing` = c(0,1,2,3) 

missing = sapply(segment, function(x) sum(is.na(x)))

# Missing output
# KJIS10 CSDF32  X   ASDF67 
#      0      0  3        2      

# What I'm trying to achieve
# Amount Missing Frequency
#              0         2
#              1         0
#              2         1
#              3         1

丢失量是每列丢失的数据量。没有列丢失的数据超过3条。我将如何进行这种计数?

0 个答案:

没有答案