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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:46:20+00:00 2026-05-28T19:46:20+00:00

I have a 3 column data frame which looks a little like this: id

  • 0

I have a 3 column data frame which looks a little like this:

    id      name    links
1   134235  dave    "34657","34563","23459" 
2   23459   mary    "134235","45868","45677"
3   165432  jane    "134235","23459","44657"

where id and name values are unique, and links is a string of ids which indicate an association with some of the names in each row. So for example dave includes the links id 23459 which is mary so dave is connected to mary. What I need to produce is a pair list of all the connections in the data so with the example data I would output something like:

dave,mary
mary,dave
jane,dave
jane,mary

Very new to R and seen amazing things done with methods like apply and before going off and trying to replicate a solution which would look more like a javascript routine and be very inefficient I wondered if anyone could help.

  • 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-28T19:46:21+00:00Added an answer on May 28, 2026 at 7:46 pm

    One solution, using Matt’s dput():

    tab <- structure(list(
      id = c("134235", "23459", "165432"),
      name = c("dave", "mary", "jane"),
      links = c("'34657', '34563', '23459'",
                "'134235', '45868', '45677'", 
                "'134235', '23459', '44657'")),
      .Names = c("id", "name", "links"),
      row.names = c(NA, -3L), class = "data.frame")
    
    conns <- function(name, links) {
      paste(name, tab$name[tab$id %in% as.numeric(unlist(strsplit(gsub('\'|\"',
        '', links), ',')))], sep=',')
    }
    
    connections <- unname(unlist(mapply(conns, tab$name, tab$links, 
      SIMPLIFY=FALSE)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large data frame (named z ) that looks like this: RPos
I have a data.frame named pp that looks like this: > head(pp) X02R X03N
I have a varchar column that has data like this top<somenumber> so the word
Let's say I have a data frame, like this: df <- data.frame( variable =
I have got a data frame (which is called data.set.y). And I would like
I have a data frame where one particular column has a set of specific
I have a data frame with two columns. First column contains categories such as
If I have a table column with data and create an index on this
I have a data frame which can be generated with: a <- c(rep(w,3), rep(x,3),
I have a data.frame in R which has been constructed off the Example 1-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.