Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5975101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:02:09+00:00 2026-05-22T21:02:09+00:00

I’m having a problem with R code, rather, with missing values. Don’t know actually,

  • 0

I’m having a problem with R code, rather, with missing values. Don’t know actually, how to impute those values using simple Hot Deck method. Like, example, having these data.

1  10000123  111  112820 0.24457235         NA        NA         NA         NA     11
2  10000132  111 2502357 0.19408587 0.19373610 0.6567305 0.01454520 0.13498823     69
3  10000388  111 4472360 0.14774927 0.14918678 0.6853377 0.05233508 0.11314044    106
4  10000792  111  666909 0.10520063         NA        NA         NA         NA     14
5  10002737  111 1139613 0.19944986 0.20114918 0.3564355 0.20135391 0.24106136     23
6  10002741  111  981574 0.11573570         NA        NA         NA         NA     13
7  10002929  111 1417192 0.08770932 0.08387991 0.6106012 0.11078473 0.19473415     24
8  10003396  111  444966 0.19026263 0.18784110 0.5215772 0.16844381 0.12213789     24
9  10003517  111 1230589 0.16393216 0.16358568 0.4614005 0.26670712 0.10830670     19
10 10003546  111  760847 0.12384748         NA        NA         NA         NA     10

Using 5th column, need to find the nearest value, and then fill with that similar respondent in those places, where are NA values.

Thank You.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:02:09+00:00Added an answer on May 22, 2026 at 9:02 pm

    I’ve never used hot (or cold for that matter) deck sampling. However a little Googling led me to the rrp.impute function in the rrp package.

    Here’s a simple example using some synthetic data:

    install.packages("rrp")
    require(rrp)
    set.seed(1)
    key <- 1:100
    ## create random values
    value1 <- 10 + 2 * key + rnorm(100, 0, 10)
    ## make 5 values into NAs
    missing <- sample( key, 5)
    value1[missing] <- NA
    ## build a dataframe
    df <- data.frame(key, value1)
    ## do a nearest neighbor hot deck interpolation
    imputed <- rrp.impute( df )$new.data
    
    ## let's visualize this magic
    plot( df)
    points(missing, imputed$value1[missing], col="red")
    

    This uses the default value of k=1, which is what I think you want. The pretty picture at the end looks like this:

    enter image description here

    The red circles are the imputed values and you can see they are simply the nearest neighbor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.