Imputation in R

前端 未结 3 1433
别跟我提以往
别跟我提以往 2021-02-01 10:58

I am new in R programming language. I just wanted to know is there any way to impute null values of just one column in our dataset. Because all of imputation co

3条回答
  •  故里飘歌
    2021-02-01 11:57

    There are plenty of packages that can do this for you. (a little more information about the data could help suggesting you the best options)

    One example can be using the VIM package.

    It has a function called kNN (k-nearest-neighbor imputation) This function has a option variable where you can specify which variables shall be imputed.

    Here is an example:

    library("VIM")
    kNN(sleep, variable = c("NonD","Gest"))
    

    The sleep dataset I used in this example comes along with VIM.

    If there is some time dependency in your columns you want to impute using time series imputation packages could also make sense. In this case you could use for example the imputeTS package. Here is an example:

      library(imputeTS)
      na.kalman(tsAirgap)
    

    The tsAirgap dataset used here as an example comes also along with imputeTS.

提交回复
热议问题