0

So I am trying to work out the mean for a column on my dataset. When I use the code

mean(dataset$`name of column`)

it returns

'argument is not numeric or logical: returning NA'.

I have tried various ways to try and get around it but nothing will work

Initially the data had NA values, which I though was the issue, in it but I have removed them, by creating a dataframe, yet it still returns the same error message. I don't understand why this has happened as all data is numerical.

Sorry if this isn't well explained I'm pretty new to R.

Heikki
  • 2,214
  • 19
  • 34
Luke
  • 11
  • 4
    It is because the column may not be numeric class. check `class(dataset$yourcolumnname)` – akrun Oct 30 '20 at 20:51
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Oct 30 '20 at 20:53
  • Thank you it has come back as a character rather than numeric which explains the problem. – Luke Oct 30 '20 at 21:40

0 Answers0