r - How to edit the numbers on ggplot y axis -


i trying create nice barplot data. far have been using ggplot function:

    library(ggplot2)     ggplot(dframe1, aes(x=site, y=lambda.max)) + geom_bar(stat="identity") +      labs(x="site", y="lambda maximum") 

this far have come with

the data on y axis needs in hundreds though (not thousands), , not know how change that. wondering if possible represent of data on 1 barplot or graph?:

    structure(list(site = structure(c(2l, 2l, 2l, 2l, 3l, 3l, 3l,      3l, 3l, 4l, 4l, 4l, 4l, 5l, 5l, 1l, 1l, 1l), .label = c("6",      "2", "3", "4", "5"), class = "factor"), weight = c(0.193, 0.249,      0.263, 0.262, 0.419, 0.204, 0.311, 0.481, 0.326, 0.657, 0.347,      0.239, 0.416, 0.31, 0.314, 0.277, 0.302, 0.403), cell.count = c(2530000,      729000, 336000, 436000, 292000, 0, 2e+05, 6450000, 2e+05, 18700000,      7430000, 9920000, 22700000, 21600000, 227000, 169000, 5e+05,      283000), eleocyte = c(1270000, 17, 7.3, 264000, 0, 0, 2e+05,      0, 2e+05, 2270000, 0, 9920000, 22700000, 442, 153000, 169000,      5e+05, 283000), lambda.max = c(459l, 459l, 459l, 459l, 462l,      462l, 462l, 462l, 462l, 465l, 465l, 465l, 465l, 490l, 490l, 475l,      475l, 475l), avepb.ppm = c(390.2, 373.3, 340.13, 403.2, 248.53,      206.7, 238.5, 190.6, 597.2, 206.8, 174.4, 186.3, 138.5, 269.55,      58.1, 5.225, 4.02, 6.85), aveworm.pb.ppm = c(9.59, 9.446, 4.193,      21.9, 1.66, 7.415, 13.11, 3.01, 51.5, 5.985, 4.705, 26.38, 2.38,      4.44, 4.67, 0.11, 0.085, 0.096), aveworm.g = c(0.09125, 0.264,      14.699, 0.2425, 0.4793, 0.051, 0.0635, 0.0465, 0.2645, 0.0559,      0.0795, 0.05765, 0.0846, 0.457, 0.0625, 0.0535, 0.1576, 0.16)), .names = c("site",      "weight", "cell.count", "eleocyte", "lambda.max", "avepb.ppm",      "aveworm.pb.ppm", "aveworm.g"), row.names = c(na, -18l), class = "data.frame") 

(1) how change y hundred separated

the continuous_y_axis gives few options comma, dollar, percent. don't think hundred want built in.

however, can divide y unit (100) in case. , add unit y label.

library(ggplot2) unit <- 100 ggplot(dframe1, aes(x=site, y=lambda.max/unit)) + geom_bar(stat="identity") +    labs(x="site", y=paste0("lambda maximum: unit: ", unit)) 

enter image description here

(2) can fit data 1 plot

i don't think idea fit variables 1 plot. dodged bar plot here. because variables in different scale , if fit of them 1 plot. of them unnoticable.

here facet_wrap , reshape can you.

library(reshape2) dframe2 <- melt(dframe1, id="site") ggplot(dframe2, aes(x=site, y=value)) + geom_bar(stat="identity") + facet_wrap(~variable, scales="free") 

enter image description here

(3) dont sum within group

in case, records inside each site need treated individual record, in case, created variable called row each record, can improve part.

dframe1$row <- row.names(dframe1) library(reshape2) dframe2 <- melt(dframe1, id=c("site", "row")) ggplot(dframe2, aes(x=as.numeric(row), fill=site, y=value)) + geom_bar(stat="identity") + facet_wrap(~variable, scales="free") 

enter image description here


Comments

Popular posts from this blog

wordpress - .htaccess: RewriteRule: bad flag delimiters -

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -