Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1092375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:40:21+00:00 2026-05-16T23:40:21+00:00

Suppose I have an R data frame with columns that specify location (lat/long), height,

  • 0

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):

  1. What percentage of individuals in each bin are female
  2. What is the average height of males in each bin

If possible I’d like to use ggplot2.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:40:22+00:00Added an answer on May 16, 2026 at 11:40 pm

    See the cut function for a way to convert from lat/lon to bins (also look at the see also section of the help on cut for other options). This assumes that a rectangular grid is good enough, you will need to look at the spatial packages if the area is big enough for the curvature of Earth to affect things.

    Then use tapply or the plyr package to compute your summaries within each cell of the grid.

    Now plot the results however you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose that you have a data frame with many rows and many columns. The
Suppose I have a data frame with columns c1, ..., cn, and a function
Suppose I have a data frame, df, that looks like: f t1 t2 t3
I have an R data frame containing a factor that I want to expand
Suppose that we have a data frame that looks like set.seed(7302012) county <- rep(letters[1:4],
I have a data.frame, d1, that has 7 columns, the 5th through 7th column
Suppose I have a data frame in R that has names of students in
Suppose I have the following data frame: Data1 X1 X2 1 15 1 2
Suppose I have a dataframe like this one: df <- data.frame (id = c(a,
Suppose I have a class that processes some data: class SomeClass { public: void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.