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

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -