@hemantsain55 wrote:
I used Hmisc package to impute my missing values and after replacing back in data frame i noticed that my variable types has changed in some “impute” type which is not recognised by many algorithms and i can not feed my data.
I want to get rid of this ‘Impute’ type of variable class and change my variable classes to back to normal data types like factors and integer.
already tried as.factors and as.integerbut nothing happened.please refer below R code :
library(Hmisc) impute_arg <- aregImpute(~ `Gender`+`Age`+`Size of City`+`Size of City`+ `Hair Color`+`Body Height [cm]`+`country_count`+`past_yeas`+ `University Degree`,data = df, n.impute = 5,match = "closest") imputed <- as.data.frame(impute.transcan(impute_arg, imputation=1, data=df, list.out=TRUE, pr=FALSE, check=FALSE)) df = cbind(imputed,df[,c('Country','Profession','Wears Glasses')])
when I checked classes i got
sapply(df, class)
Output:
$Gender [1] "impute" "factor" $Age [1] "impute" $`Size of City` [1] "integer" $`Hair Color` [1] "impute" "factor" $`Body Height [cm]` [1] "integer" $country_count [1] "integer" $past_yeas [1] "impute" $`University Degree` [1] "impute" "factor" $Country [1] "factor" $Profession [1] "factor" $`Wears Glasses` [1] "integer"
My Desired Output:
$Gender [1] "factor" $Age [1] integer $`Size of City` [1] "integer" $`Hair Color` [1] "factor" $`Body Height [cm]` [1] "integer" $country_count [1] "integer" $past_yeas [1] integer $`University Degree` [1] "factor" $Country [1] "factor" $Profession [1] "factor" $`Wears Glasses` [1] "integer"
Posts: 1
Participants: 1