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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:47:30+00:00 2026-05-28T20:47:30+00:00

I have markr variable which are arranged in order and correlation between subsequent members

  • 0

I have “markr” variable which are arranged in order and correlation between subsequent members of “markr” is provided in corr variables.

markr <- c("A", "B", "C", "D", "E",  "g", "A1", "B1", "cc", "dd", 
     "f", "gg", "h", "K")
corr <- c(     1,   1,   1,   1, 0.96,   0.5,  0.96,        1 ,   1 ,  
       1 ,  0.85, 0.99, 1)

I need to group markr based on corr without changing the order of members of markr. The group can be better explained by following diagram:

enter image description here

The individual members of abject markr that have corr greater than 0.95 will be in one group. Starting from first value when the corr drops to less than 0.95, then second group starts and continues till the corr drops again below 0.95, the process continues to end of the data. The group variable are named by first and last members in the group for example – A-g, A1-f, gg-k.

Thus expected output is.

markr <- c("A", "B", "C", "D", "E",  "g", 
           "A1", "B1", "cc", "dd", "f", 
           "gg", "h", "K")
group <- c("A-g", "A-g", "A-g", "A-g","A-g", "A-g", 
           "A1-f",  "A1-f",  "A1-f",  "A1-f","A1-f", 
            "gg-k", "gg-k", "gg-k")
dataf <- data.frame (markr, group) 

dataf 

 markr group
1      A   A-g
2      B   A-g
3      C   A-g
4      D   A-g
5      E   A-g
6      g   A-g
7     A1  A1-f
8     B1  A1-f
9     cc  A1-f
10    dd  A1-f
11     f  A1-f
12    gg  gg-k
13     h  gg-k
14     K  gg-k

How can I automate this process as I have very large such dataset.

  • 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-28T20:47:31+00:00Added an answer on May 28, 2026 at 8:47 pm

    The number of the group is the number of values under 0.95 we have seen so far:

    d1 <- data.frame(
      marker = markr,
      group = cumsum(c(1, corr < .95))
    )
    

    For the group names, you can use ddply the cut the data.frame into pieces, one per group: it is then easy to extract the first and last element.

    library(plyr)
    d2 <- ddply( 
      d1, "group", summarize, 
      group_name=paste(head(marker,1), tail(marker,1), sep="-")
    )
    d <- merge(d1, d2, by="group")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather large SQL file which starts with the byte order marker
I have list in SML, which contains members from datatype expr (list b). I
What I'm currently doing is this: I have a $path variable, which is everything
I have a JSF page that accepts a viewparam and sets a variable which
I have project in development where string operations like Hi + variable + ,
Straightforward question: I have a few variables that are doubles. I would like to
I have a stupid question :) I'm working on a simple php document which
I have a multithreaded Java code in which: several threads read stateful objects from
I have a vector (order is important) of objects (lets call them myobj class)
I have this JavaScript which should loop through my XML and get my data.

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.