0

I want to replace missing or N/A values in a csv file with mode. The column consists of strings. Column name is "embarked". I tried this

embarked.mode <- mode(data$Embarked, na.rm=TRUE) data$Embarked[is.na(data$Embarked)] = embarked.mode

I am getting the following error

Error in mode(data$Embarked, na.rm = TRUE) : unused argument (na.rm = TRUE)

Please help me how to replace them with mode without impute.

yahooo
  • 103
  • 9
  • https://stackoverflow.com/questions/2547402/is-there-a-built-in-function-for-finding-the-mode – Phil Sep 14 '18 at 02:47
  • `mode` is not the most common value but the storage mode of the object. e.g. `mode(1)` is 'numeric', `mode("abc")` character etc. – Hugh Sep 14 '18 at 03:15

1 Answers1

0

To get the most frequent value,try:

names(which.max(table(data$Embarked,useNA="no")))
harryjerry
  • 66
  • 3