Imputing missing values linearly in R
I have a data frame with missing values: X Y Z 54 57 57 100 58 58 NA NA NA NA NA NA NA NA NA 60 62 56 NA NA NA NA NA NA 69 62 62 I want to impute the NA values linearly from the known values so that the dataframe looks: X Y Z 54 57 57 100 58 58 90 59 57.5 80 60 57 70 61 56.5 60 62 56 63 62 58 66 62 60 69 60 62 thanks Base R's approxfun() returns a function that will linearly interpolate the data it is handed. ## Make easily reproducible data df <- read.table(text="X Y Z 54 57 57 100 58 58 NA NA NA NA NA NA NA NA NA 60 62 56 NA NA NA NA NA NA 69 62 62", header=T) ## See how this works on a