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 6652793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:11:08+00:00 2026-05-26T01:11:08+00:00

I have dataframe that contains 70-80 rows of ordered response time (rt) data for

  • 0

I have dataframe that contains 70-80 rows of ordered response time (rt) data for each of 228 people each with a unique id# (everyone doesn’t have the same amount of rows). I want to bin each person’s RTs into 5 bins. I want the 1st bin to be their fastest 20 percent of RTs, 2nd bin to be their next fastest 20 percent RTs, etc., etc. Each bin should have the same amount of trials in it (unless the total # of trial is odd).

My current dataframe looks like this:

id     RT
7000   225
7000   250
7000   253
7001   189
7001   201
7001   225

I’d like my new dataframe to look like this:

id   RT    Bin
7000  225    1
7000  250    1

After getting my data to look like this, I will aggregate by id and bin

The only way I can think of to do this is to split the data into a list (using the split command), loop through each person, use the quantile command to get break points for the different bins, assign a bin value (1-5) to every response time. This feels very convoluted (and would be difficult for me). I’m in a bit of a jam and I would greatly appreciate any help in how to streamline this process. Thanks.

  • 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-26T01:11:09+00:00Added an answer on May 26, 2026 at 1:11 am

    The answer @Chase gave split the range into 5 groups of equal length (difference of endpoints). What you seem to want is pentiles (5 groups with equal number in each group). For that, you need the cut2 function in Hmisc

    library("plyr")
    library("Hmisc")
    
    dat <- data.frame(id = rep(1:10, each = 10), value = rnorm(100))
    
    tmp <- ddply(dat, "id", transform, hists = as.numeric(cut2(value, g = 5)))
    

    tmp now has what you want

    > tmp
        id       value hists
    1    1  0.19016791     3
    2    1  0.27795226     4
    3    1  0.74350982     5
    4    1  0.43459571     4
    5    1 -2.72263322     1
    ....
    95  10 -0.10111905     3
    96  10 -0.28251991     2
    97  10 -0.19308950     2
    98  10  0.32827137     4
    99  10 -0.01993215     4
    100 10 -1.04100991     1
    

    With the same number in each hists for each id

    > table(tmp$id, tmp$hists)
    
         1 2 3 4 5
      1  2 2 2 2 2
      2  2 2 2 2 2
      3  2 2 2 2 2
      4  2 2 2 2 2
      5  2 2 2 2 2
      6  2 2 2 2 2
      7  2 2 2 2 2
      8  2 2 2 2 2
      9  2 2 2 2 2
      10 2 2 2 2 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame that contains a long character string each associated with
I have a column in a dataframe that contains an ordered factor. I summarize
So I have a data frame in R that contains integers, NA's, and a
I have data.frame that contains several factors and i want to rename factor levels
Say I have a dataframe source <- data.frame(ID=c(1,2), COUNT=c(3,4)) that looks like this: ID
I have a data.frame that has a number of duplicate rows, akin to something
i have a data frame that contains a data like this : V1 V2
I have a dataframe with approximately 500,000 rows and four columns. The dataframe contains
Possible Duplicate: removing specific rows from a dataframe Let's say I have a data
I have a data.frame that contains historic data by day for several months. I

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.