R: How to find the mean of a column in a data frame, that has non-numeric (specifically, dashes '-') as well as numeric numbers -
example of entries in data frame:
i need find mean of column in data frame, can't find mean says:
" argument not numeric or logical: returning na"
the non-numeric entries dash signs, have tried converting them na still struggling produce result mean.
can help?
try this, assuming data called dat
:
dat[dat == "-"] <- na mean(dat$population_and_people, na.rm = true]
Comments
Post a Comment