Deleting all the rows that have some missing values using R -


this question has answer here:

i working csv data set around 1 million records. need perform 2 operations on data set:

  1. prepare dataset not have rows have missing (blank) values in them.
  2. prepare data set replaces empty values unknown.

i have tried use excel taking time. please way can done in r?

to complete cases, use this:

complete_df <- df[complete.cases(df),] 

complete.cases returns logical vector tells rows of dataframe df complete, , can use subset data.

to replace nas, can use this:

new_df <- df new_df[is.na()] <- 'unknown' 

but has effect of possibly changing datatypes of columns missing data. example, if have column of numeric data , put missing variables 'unknown' whole column character variable, aware of this.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -