R Remove Data Frame Rows with NA Values | na.omit, complete.cases, rowSums, is.na, drop_na & filter

preview_player
Показать описание
R code of this video:

x2 = c("A", NA, NA, "XX", "YO", "YA"),
x3 = c(1, 0, NA, 1, 1, NA))

library("tidyr")

data4 <- data %>% drop_na() # Apply drop_na function

library("dplyr") # Load dplyr package

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

As always, very good tutorial, I will share it with another friend of mine, he is about to start a course involving R. He will certainly find it use full.

agsoutas
Автор

Very useful--especially with various ways to remove NAs.

dangunwangum
Автор

Keep making great videos. I learn so much from you

leighmellish
Автор

Thank you so much! How about all the missing values recorded as certain values ( for example -9). Is there any way I can drop the records containing -9( missing value) from my dataset?

hsinchuenhsu
Автор

Many thanks for this video. However, I get really confused with the "data" here. Which "data" used in the program is the command, and which is the defined/created file as "data" in the data 5 command please? Thanks

meimeihechuan
Автор

Its impressive tutorial. Dear Dr if you have a tutorial regarding piecewiseSEM packages in r or path analysis please share us.

meseretmuche
Автор

Thank you for the very useful video, I have tried using the na.omit function on my data however the NAs are still included, do you know why this could be?
Edit: I just noticed that the class of the column was 'character' haha, that must be why so I'll have to change it to the class 'numeric'. Thanks again!

edwarda.
Автор

I am wondering if the methods in the videos only work for numeric data? May I ask how I can remove a missing value if the values in the column are stored as "character" (this is the problem I am facing now)? I have tried na.omit(), complete.cases() and drop_na(), but none of these methods work. I see a comment says we can change the class as numeric, but if the other values are like "male", "female", or country names, how can I turn the values in the column into numeric? Sorry, I am a beginner learner, hope it is not a silly question.

timding
Автор

Drop_na, complete.cases worked perfectly on R studio .
But when I write the same code in kaggle new data frame doesn't have any value ??
Any suggestions ???

mayankvermashubhamkaran
Автор

If a data frame has several columns filled with NA but if i want to replace NA values in different rows with eg Visual, 16S or 12S how do i do that please? Thank you

krikamoleno
Автор

OK - thumbs down - you left out the one case I needed! You left out the example of the code that will remove only the rows with ALL whsy did you leave that one out! You should redo this video and include it.... I still saved it for future reference.

greggapowell