zara
zara

Reputation: 1098

How to fix the unit values in ggplot2 in R?

I am trying to make a plot and my data looks like this:

diversity position
113 2098776
116 4598777
67 5626222
200 6423068
...

and I used this script:

qplot(position, diversity, data = FILE)

but when plot appears, in x axis I see values like 0e+00 1e+07 , but i want to convert these values begin from 0 to 60 instead.. any guide please?

Upvotes: 0

Views: 218

Answers (2)

baptiste
baptiste

Reputation: 77096

you could rescale the data,

qplot(scales::rescale(position, c(0,60)), diversity, data = FILE)

Upvotes: 2

Imran Ali
Imran Ali

Reputation: 2279

Make sure you load the scales package library(scales) and then Try this qplot(position, diversity, data = yourdataframe) + scale_x_continuous(labels = comma)

Upvotes: 2

Related Questions