i am new in R and I am trying to visualize mean diastolic blood pressure by location and gender. (y = mean DBP , x= residence , gender)
i know I can do this by ggplot, bar, and hist function but I can't understand some function.
ggplot(df, aes(x = Residence, y = mean , fill= Gender))
geom_histogram(bins = 6, position = "dodge")
for example, what are bins?? or position?
could you please recommend me resources for learning this in detail?
As shown in the examples below, bin controls how finely subdivided the data are plotted. Position controls side-by-side vs. stacked. See `help(geom_historgram)'. A great guide to using ggplot is The R Graphics Cookbook by Winston Chang. It's well worth buying a physical copy.
suppressPackageStartupMessages({
library(dplyr)
library(ggplot2)
library(qrmix) # for blood pressure data
})
blood.pressure %>%
ggplot(., aes(x = systolic , fill= gender)) +
geom_histogram(bins = 15, position = "dodge") +
theme_minimal()