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:
- prepare dataset not have rows have missing (blank) values in them.
- 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
Post a Comment