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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:49:39+00:00 2026-06-11T14:49:39+00:00

Hi I have a table with comma delimited columns and I need to convert

  • 0

Hi I have a table with comma delimited columns and I need to convert the comma delimited values to new rows. for exmaple the given table is

Name     Start      End 
A        1,2,3    4,5,6
B          1,2      4,5
C      1,2,3,4  6,7,8,9   

I need to convert it like

Name Start End
   A     1   4
   A     2   5  
   A     3   6
   B     1   4
   B     2   5 
   C     1   6
   C     2   7
   C     3   8   
   C     4   9

I can do that using VB script but I need to solve it using R
Can anyone solve this?

  • 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-11T14:49:40+00:00Added an answer on June 11, 2026 at 2:49 pm

    Here’s an approach that should work for you. I’m assuming that your three input vectors are in different objects. We are going to create a list of those inputs and write a function that process each object and returns them in the form of a data.frame with plyr.

    The things to take note of here are the splitting of the character vector into it’s component parts, then using as.numeric to convert the numbers from the character form when they were split. Since R fills matrices by column, we define a 2 column matrix and let R fill the values for us. We then retrieve the Name column and put it all together in a data.frame. plyr is nice enough to process the list and convert it into a data.frame for us automatically.

    library(plyr)
    
    a <- paste("A",1, 2,3,4,5,6, sep = ",", collapse = "")
    b <- paste("B",1, 2,4,5, sep = ",", collapse = "")
    c <- paste("C",1, 2,3,4,6,7,8,9, sep = ",", collapse = "")
    
    input <- list(a,b,c)
    
    splitter <- function(x) {
        x <- unlist(strsplit(x, ","))
        out <- data.frame(x[1], matrix(as.numeric(x[-1]), ncol = 2))
        colnames(out) <- c("Name", "Start", "End")
        return(out)
    }
    
    
    ldply(input, splitter)
    

    And the output:

    > ldply(input, splitter)
     Name Start End
    1    A     1   4
    2    A     2   5
    3    A     3   6
    4    B     1   4
    5    B     2   5
    6    C     1   6
    7    C     2   7
    8    C     3   8
    9    C     4   9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with rows of data and need to create a comma
I have a MySQL table that has a field of comma separated values. How
products table (mySQL) record_id categories (comma-delimited list) --------- -------------------------------- 1 960|1,957|1,958|1 I have the
I have a comma delimited list like this saved in a mysql table: -----------------
I have a DB table that contains a comma separated list of ID's (ints)
I have table with around 70 000 rows. There is 6000 rows that i
I have table in which I am inserting rows for employee but next time
Here is my dillema... I have a directory full of .txt comma delimited files
I’m looking to split '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15...' (comma delimited) into a table or table variable. Does
I have two tables: EmployeeTypeA table Name varchar(2000) field contains - 'john,sam,doug' EmployeeTypeB table

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.