r - Changing the x-axis labels of a ggplot histogram -


i have following dataset (edited readability):

chol <- read.table(url("http://assets.datacamp.com/blog_assets/chol.txt"), header = true) 

and creating histogram of data doing:

ggplot(data=chol, aes(chol$age)) + geom_histogram() 

for particular example change x-labels however.

any thoughts on how can pull of?

to illustrate answer (and better understand question) picture:

> require(ggplot2) > chol <- read.table(url("http://assets.datacamp.com/blog_assets/chol.txt"), header = true) > ggplot(data=chol, aes(chol$age)) + geom_histogram() 

yields:

the plot

there documentation (as have continuous not discrete axis) @ http://docs.ggplot2.org/current/scale_continuous.html

for discrete axis 1 might have written:

> p <- ggplot(data=chol, aes(chol$age)) + geom_histogram() + scale_x_discrete(labels=c("20" = "twe", "30" = "thi", "40" = "fou", "50" = "fif", "60" = "six"))  # not work cf. surrounding text. 

a continuous axis @ least allows formatting (cf. link details).


Popular posts from this blog

node.js - How do I prevent MongoDB replica set from querying the primary? -

Apache NiFi ExecuteScript: Groovy script to replace Json values via a mapping file -