In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to analyze the missing values in R language. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
The md.pattern () function in the mice function generates a table showing the missing value pattern in the form of a matrix cargo data box, and applies the function to the sleep dataset:
> library (mice)
Data (sleep,package= "VIM")
> md.pattern (sleep)
The running result of BodyWgt BrainWgt Pred Exp Danger Sleep Span Gest Dream NonD shows that 0 indicates that there are missing values in the variable column, 1 indicates the missing value in the variable column, the first row indicates no missing value, the second row indicates no missing value except span, the first column represents the number of instances of each missing value pattern, and the last column represents the number of variables with missing values in each mode. It can be seen that 42 cases in the sleep dataset have no missing values, only 2 instances are missing span,9 instances and both NanD and Dream are missing. The dataset contains a total of 42x0+2x1+.1x3=38 missing values.
The aggr () function plots not only the number of missing values for each variable, but also the number of missing values for each combination of variables, code:
> library (VIM)
> aggr (sleep,prop=FALSE,numbers=TRUE)
Running result:
The figure on the left shows the number of missing values, the maximum number of missing values in NonD is 14, and the figure on the right shows that 2 mammals have missing NonD, Dream, and Sleep scores. 42 animals had no missing value.
> aggr (sleep, prop = TRUE, numbers = TRUE) # generates the same graph, but replaces the count with scale. Numbers = FALSE deletes the numeric label by default.
> matrixplot (sleep)
The running results are as follows:
The number of numerical types is converted to the [0 ~ (1)] range, which is represented by grayscale, where light color indicates small value, dark color indicates large value, and red indicates missing value.
> marginplot (sleep [c ("Gest", "Dream")], pch=c (20), col=c ("darkgray", "red", "blue")) # the relationship between dream time and mammalian pregnancy time. Pch and col are symbols and colors for drawing graphics.
The running results are as follows: the main body of the graph is the scatter chart of Gest and Dream (the data of the two variables are complete). The box chart on the left shows the distribution of Dream variables (dark gray) and excluding (red) Gest. Note that red is a darker shadow on the grayscale image. Four red dots represent the missing Dream value of the Gest score. On the bottom boundary, it can be seen that there is a negative correlation between pregnancy and dreaming time, and the dreaming time of animals is generally longer in the absence of pregnancy data. The number of observations with missing values in both variables is marked in blue at the intersection of the two boundaries (lower left corner).
So much for the analysis of missing values in R language. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.