r - Boxplot with continuous and discrete x variables -


i trying make box plot without faceting. data this:

species elevation hbl datae 400 83 datae 300 92 datae 257 92 datae 350 102 datae 500 89 datae 625 100 datae 625 94 datae 632 87 datae 1000 100 datae 940 89 datae 1050 98 datae 550 79 datae 700 102 datae 638 86 abrae 1500 71 abrae 1600 80 abrae 1405 80 abrae 1470 90 abrae 1000 77 abrae 1125 88 abrae 1125 82 abrae 1132 75 abrae 1500 88 abrae 1440 77 abrae 1550 86 abrae 1050 67 abrae 1200 90 abrae 1138 74 abrae 1000 83 abrae 1100 92 abrae 905 92 abrae 970 102 abrae 500 89 abrae 625 100 abrae 625 94 abrae 632 87 abrae 1000 100 abrae 940 89 abrae 1050 98 mingan 1000 120 

the code below produces box plot pools hbl values 2 species of interest when both present in single bin of elevation, giving red (abrae), blue (datae), , grey (both), separate boxes each species in bins, on same plot. missing?

library(ggplot2) d = read.csv("path_to_file") p = ggplot(d[d$species=="abrae" | d$species=="datae",], aes(x=elevation, y=hbl, fill=species, group=cut_interval(x=elevation, length=200))) p + geom_boxplot() 

resulting boxplot data abraee , datae pooled

ggplot(d[d$species=="abrae" | d$species=="datae",], aes(x=cut_interval(x=elevation, length=200), y=hbl, fill=species)) + geom_boxplot() 

enter image description here


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -