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:

enter image description here

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

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

.net - Generate assembly with Roslyn -

batch file - filebot superstrict script: need tiny video sample or other solution -