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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:36:32+00:00 2026-06-08T06:36:32+00:00

It seems like such a simple problem, yet i’ve been pulling my hair out

  • 0

It seems like such a simple problem, yet i’ve been pulling my hair out trying to get this to work:

Given this data frame identifying the interactions idhad with contact who is grouped by contactGrp,

head(data)
   id               sesTs  contact    contactGrp   relpos   maxpos
1 6849 2012-06-25 15:58:34   peter        west    0.000000      3
2 6849 2012-06-25 18:24:49   sarah        south   0.500000      3
3 6849 2012-06-27 00:13:30   sarah        south   1.000000      3
4 1235 2012-06-29 17:49:35   peter        west    0.000000      2
5 1235 2012-06-29 23:56:35   peter        west    1.000000      2
6 5893 2012-06-30 22:21:33   carl         east    0.000000      1

how many contacts where there for unique(data$contactGrp) with relpos=1 and maxpos>1 ?

An expected Result would be:

1 west   1
2 south  1
3 east   0

A small subset of lines i have tried:

  • aggregate(data, by=list('contactGrp'), FUN=count) yields an error, no filtering
  • using data.table seems to require a key, which is not unique in this data…
  • ddply(data,"contactGrp",summarise,count=???) not sure which function to use to fill the count column
  • ddply(subset(data,maxpos>1 & relpos==0), c('contactGrp'), function(df)count(df$relpos)) works but gives me an extra column x and it feels like i’ve overcomplicated it…

SQL would be easy: Select contactGrp, count(*) as cnt from data where … Group by contactGrp but im trying to learn R

  • 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-08T06:36:35+00:00Added an answer on June 8, 2026 at 6:36 am

    I think this is the ddply version you’re looking for:

    ddply(sessions,.(contactGrp),
          summarise,
          count = length(contact[relpos == 0 & maxpos > 1]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this seems like such a simple problem but I have been unable to find
This seems like a really, really simple problem, but I can't figure it out.
This seems like such a simple task, yet I am unable to find a
So this seems like such a simple problem but i am struggling with it.
This seems like such a simple issue but I cannot find an elegant solution.
This seems like such a simple question. I have several Edit boxes on my
This is driving me absolutely bonkers, and it seems like such a simple thing
This seems like such a simple question, but I'm having such difficulty with it.
This seems like it should be a well known problem, but I haven't been
Why does Java not have a file copy method? This seems like such an

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.