-4

I am provided with a dataset and I am asked to perform binning based on a particular column value. Here the column value is in factor when I tried converting to numeric I am getting either the NA coercion or getting the factor values but not the data in the table.

data$imdbVotes <- as.numeric(as.character(data$imdbVotes))

When I tried with this code I got the error:

Warning message: NAs introduced by coercion

This is the table provided and I have to perform binning based on IMDB votes.

enter image description here

Jaap
  • 81,064
  • 34
  • 182
  • 193
Prishi Kumar
  • 81
  • 1
  • 2
  • 9
  • Warnings are not errors. Check the result. – Rich Scriven Sep 22 '16 at 18:47
  • 3
    Welcome to StackOverflow! Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610). This will make it much easier for others to help you. – Jaap Sep 22 '16 at 19:01
  • 1
    don't post images, they don't help to understand your problem. Explanation with example data and the errors you get is the only way to understand. read how to ask questions in SO. Good luck – user5249203 Sep 22 '16 at 20:23

1 Answers1

0

Hi Nice meeting you out of Edwisor. What you are doing is perfectly right. There have to be some NAs in the file.

For example if you try tail(data,7) you will see that the value of imdbVotes for the movie Venky is missing. Now we have two options. Either get the data for this item. Or keep it as NA.

In an ideal scenario when the data is critical, I would extract the data again so that there are no missing values. In this case, I am going to leave it as NA, so it doesn't mess with the calculations.

Hamza Zubair
  • 1,232
  • 13
  • 21