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

  • Home
  • SEARCH
  • 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 7901871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:20:41+00:00 2026-06-03T09:20:41+00:00

If I have the following data set: c1 c2 — — 1 5 1

  • 0

If I have the following data set:

c1   c2
---  ---
1    5
1    5
1    6
2    9
2    9
3    1
3    2

I want to return the most frequently occurring value in the second column (c2) for each value in the first column (c1). So I would want the returning data set to look like the following since for c1=1 the value “5” occurs twice and the value “6” only occurs once and for c1=2, the value of “9” occurs twice and no other value occurs:

1    5
2    9
3    1

The case I am having problems with is where there is an equal number of occurrences (in this case where c1=3.) In the case (c1=3) where there is an equal number of occurring values in c2 then I just want the first occurrence returned.

Any ideas would be helpful.

  • 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-06-03T09:20:42+00:00Added an answer on June 3, 2026 at 9:20 am

    Assuming you have your c1 and c2 on A :

    B = GROUP A BY (c1, c2)
    C = FOREACH B GENERATE GROUP, COUNT(A) as num;
    
    D = GROUP C BY GROUP.c1
    E = FOREACH D {
        SA = ORDER C BY num DESC;
        SB = LIMIT SA 1;
        GENERATE FLATTEN(SB.group);
    }
    

    should solve your problem. (I wrote in notepad though, you should check if any flatten needed via describe/illustrate)

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

Sidebar

Related Questions

I have the following data set that I am trying to plot with ggplot2,
I have the following set of data: ID | CREATED | USER -------------------------- 1
I have the swiss data set provided by R, which has the following form:
I have following data in my table. alt text http://img26.imageshack.us/img26/3746/productfield.png I want to extract
I have the following data set called t : n <- 12 t <-
I have the following Data template with triggers: <DataTemplate.Triggers> <DataTrigger Binding={Binding IsCalled} Value=Yes> <Setter
I have the following Data Trigger set-up on a Control Template <DataTrigger Binding={Binding Path=IsDragged}
I have a large data set and i want to convert it into array.
I have the following data set with the 3rd field consists of 0's and
I have a following data set: A B N 1 3 10 2 3

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.