0

I am new in R and I am trying to covert a column of my data frame which is text into numeric because I want to create scatterplot with class and values.

I am using the following command but is not working:

md$class = as.numeric(md$class)

Can anyone help me?

ctsits
  • 27
  • 6
  • Please share your dataset with us, e.g. by using `dput`. – David Heckmann Mar 21 '16 at 13:20
  • 3
    may be it is `factor` so, `as.numeric(as.character(md$class))` – Ananta Mar 21 '16 at 13:21
  • This is not enough information to really help. A common source of mistakes is that entries are often stored as factors. This can be checked with `class(md$class)`. In that case case `md$class <- as.numeric(as.character(md$class))` could help. – RHertel Mar 21 '16 at 13:22
  • if i run the command class(md$class) said that is numeric, but when I try to create scatterplot - plot(t1,md$class), I get the following error message: Error in plot.window(...) : need finite 'ylim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -In – ctsits Mar 21 '16 at 13:28
  • 1
    In that case I rather suspect that `t1` is the troublemaker. Is that a numeric vector? It's really a pity that you didn't share a sample of the data. That would have made it much easier to help. – RHertel Mar 21 '16 at 13:39
  • Voted to reopen. The OP stated that `class(md$class)` is not a factor. – RHertel Mar 21 '16 at 13:44
  • 1
    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. After updating your question, you can ask for it to be reopened (cc @RHertel). – Jaap Mar 21 '16 at 14:17
  • @ProcrastinatusMaximus Fair enough :-) – RHertel Mar 21 '16 at 14:20

0 Answers0