Imputation in R

0 votes
Is there any package in R which helps to replace NA values in a column with different criteria such as 'mean' of column, 'median' of column, 'maximum' value in column and so on.
Mar 27, 2018 in Data Analytics by Ashish
• 2,650 points
489 views

1 answer to this question.

0 votes

You can work with the "Hmisc" package, which helps you to impute columns.

Let's take this data-frame:

DF <- data.frame(cost = c(10, 20, NA, 40), fruit = c('apple','guava','banana','orange'))

Imputing with mean value:

with(DF, impute(cost, mean))

Imputing with median value:

with(DF, impute(cost, median))

Imputing with random value:

with(DF, impute(cost, 'random'))

Imputing with minimum value:

with(DF, impute(cost, min))

Imputing with maximum value:

with(DF, impute(cost, max))
answered Mar 27, 2018 by Bharani
• 4,660 points

Related Questions In Data Analytics

+2 votes
1 answer

Need a hadoop engine in backend to run r server

Dear Koushik, Hope you are doing great. The hadoop ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
821 views
0 votes
1 answer

How to change y axis max in time series using R?

The axis limits are being set using ...READ MORE

answered Apr 3, 2018 in Data Analytics by Sahiti
• 6,370 points
3,776 views
0 votes
1 answer

AUC for 3-Class prediction in R

Use type='probs' inside predict() function, so that ...READ MORE

answered Apr 4, 2018 in Data Analytics by Bharani
• 4,660 points
1,343 views
0 votes
1 answer
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
5,826 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,002 views
0 votes
1 answer

Plotting multiple graphs on the same page in R

If you want to plot 4 graphs ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,376 views
+1 vote
2 answers

Custom Function to replace missing values in a vector with the mean of values

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE ...READ MORE

answered Aug 14, 2019 in Data Analytics by anonymous
1,877 views
0 votes
2 answers

Installing MXNet for R in Windows System

You can install it for python in ...READ MORE

answered Dec 4, 2018 in Data Analytics by Kalgi
• 52,360 points
2,281 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
1,072 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