I have "one of those textbooks" that uses new concepts, synthax and vocabulary without any clarification and is largely inconsistent when providing code examples.
Said textbook had has been using the "impute" function in R (package hmisc) a few times in code examples, however the second argument was always used differently.
students is a dataframe representing students, name, age, address etc.
students$age <- impute(students%age, mean)
This is supposed to replace all NA Values in the age column of students with the mean value of the whole column. The official docs menthioned this is the standard value and could even be left out so
students$age <- impute(students%age, mean)
students$age <- impute(students%age,)
Would be the same as far as I understand
However from here on my textbook gets somewhat inconsistent and I have examples where I see things like:
students$age <- impute(students%age, fun = median)
students$age <- impute(students%age, fun = "random")
students$age <- impute(students%age, myownfunction)
I am confused to when I need to provice this second argumen as a keyword assignment using "fun = xxx" and when not and also why sometimes it is provided as a string.