How to remove NA values from a column and the corresponding values from an adjacent column in R

0 votes
I have a large dataframe and several columns are full of NAs.

Basically got a "score and class differ in length" error message in a function that doesn't support na.rm, so I want to create two new vectors from the dataframe to use for the function. One vector without the NAs, and the next vector without the corresponding values from the first.

How would I do this?
Aug 4, 2020 in Data Analytics by Marcelo
• 120 points
1,924 views

1 answer to this question.

0 votes

Hi@Marcelo,

You can use the filter keyword to find NAN values. It will search for all the position which has NAN values. 

$ df %>% filter(!is.na(col1))
answered Aug 4, 2020 by MD
• 95,440 points
Thank you for your answer @MD !

Will this filter out the corresponding values from a sector vector as well?

Related Questions In Data Analytics

0 votes
1 answer

How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

answered Jul 4, 2018 in Data Analytics by CodingByHeart77
• 3,740 points
4,244 views
+1 vote
2 answers
+1 vote
1 answer

Remove NA values from the output in R programming

Edit your code: columnmean <- function(x, removeNA = ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 52,360 points
660 views
0 votes
1 answer

How do I remove an element from a list by index in R?

Use list[index] = NULL The list value will ...READ MORE

answered Oct 31, 2019 in Data Analytics by Cherukuri
• 33,030 points
2,081 views
0 votes
2 answers

R programming: Removing NA values

Hi, Use na.rm = TRUE or Fetch values which has ...READ MORE

answered Aug 30, 2019 in Data Analytics by anonymous
• 33,030 points
830 views
+1 vote
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
1,452 views
0 votes
5 answers

How to remove NA values from a Vector in R?

Hello team, you can use na.omit x <- c(NA, 3, ...READ MORE

answered Dec 9, 2020 in Data Analytics by anonymous
• 82,880 points
192,417 views
+10 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 9, 2018 in Data Analytics by Abhi
• 3,720 points
1,164 views
0 votes
1 answer

How to remove an element from a list in R?

Hi@akhtar, You can remove a value from a ...READ MORE

answered Oct 30, 2020 in Data Analytics by MD
• 95,440 points
3,951 views
0 votes
1 answer

How to access the last value from a vector in R?

Hi@akhtar, You can use the tail function in ...READ MORE

answered Oct 30, 2020 in Data Analytics by MD
• 95,440 points
842 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP