[R] HELP - as.numeric changing column data

Andy Schneider andyschneider85 at gmail.com
Wed Jan 6 21:01:17 CET 2016


Hi -

I'm trying to plot some data and having a lot of trouble! I have a simple
dataset consisting of two columns - income_per_capita and mass_beauty_value.
When I read the data in and plot it, I get the attached plot Mass Beauty
Non-Numeric:
<http://r.789695.n4.nabble.com/file/n4716202/Mass_Beauty_Non-Numeric.jpg> .
You can see that, while it contains all the values, the income_per_capita
axis is out of order and there are some weird vertical lines happening.

To fix this, I converted both columns to numerics using:

mass_beauty$income_per_capita <- as.numeric(mass_beauty$income_per_capita)
mass_beauty$mass_beauty_value <- as.numeric(mass_beauty$mass_beauty_value)

When I did this, I noticed that my income_per_capita column's values
suddenly changed. Whereas I have values extending all the way to 30,000 or
so before, now they maxed out at around 1,400. While at first I thought they
might at least have changed to scale, it unfortunately looks like changes
were more or less random. But, they plotted much better:
<http://r.789695.n4.nabble.com/file/n4716202/Mass_Beauty_Plot.jpg> .

Does anyone have any solution for how I can convert my income_per_capita
column to a plottable numeric without changing up its values? I've tried
doing as.numeric(as.character(mass_beauty_value$income_per_capita)) but it
didn't work.

Thanks so much for your help!


More information about the R-help mailing list