R: NA removal in number vectors

I am new to R and I have some problems. I am dealing with a large data framework that I read from a csv file. Numeric vectors contain NAs that stop me from doing analyzes. How do I get rid of these NA so that I can do something with my data?

+4
source share
3 answers
  • for a specific variable: x[!is.na(x)] or na.omit (see apropos("^na\\.") for all available na. functions na. ),
  • in a function, pass na.rm = TRUE as an argument, for example. sapply(dtf, sd, na.rm = TRUE) ,
  • set the global action NA: options(na.action = "na.omit") which is installed by default, but many functions do not rely on the global specific action NA ( mean for instance), while some do (right now I cannot come up with an example)
  • and of course, if you have a lot of NA, you should consider the variable imputation, there the question asked on SO can be useful.

In short, working with NA is a very wide problem, try to specify it a bit and give us a brief question. I'm sure someone from SOers can help you!

Hi boy!

+7
source
 na.omit(dataFrame) 

This is a terrific website that I use for quick information related to R: http://www.statmethods.net/input/missingdata.html

+4
source

This can be done using the na.omit () function.

 myVec <- na.omit(myVec) 
0
source

Source: https://habr.com/ru/post/1314265/


All Articles