require (yaImpute)
data(iris)
# form some test data
refs=sample(rownames(iris),50) # just the reference observations
x <- iris[refs,1:3] # Sepal.Length Sepal.Width Petal.Length
y <- iris[refs,4:5] # Petal.Width Species
# build a yai object using mahalanobis
mal <- yai(x=x,y=y,method="mahalanobis")
# get imputations for the target observations (not references)
malNew <- newtargets(mal,iris[!(rownames(iris) %in% rownames(x)),])
# output a data frame of observed and imputed values for
# the observations that are not in the original yai object
impute(malNew,vars=yvars(malNew))Run the code above in your browser using DataLab