Suppose I have an R data frame with columns that specify location (lat/long), height, and gender of individuals:
x <- data.frame(
lat=c(39.5,39.51,38,38.1,38.2),
long=c(86,86,87,87,87),
gender=c("M","F","F","M","F"),
height=c(72,60,61,70,80)
)
I want to bin the data in two dimensions (e.g. into 1000m x 1000m squares) and compute the following (then display on a map):
- What percentage of individuals in each bin are female
- What is the average height of males in each bin
If possible I'd like to use ggplot2.