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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:14:30+00:00 2026-05-27T22:14:30+00:00

I have an arbitrary number of columns containing text data that have been assembled

  • 0

I have an arbitrary number of columns containing text data that have been assembled using the cbind() command, for example:

[1,] "Text 1,1" "Text 1,2" "Text 1,n"
[2,] "Text 2,1" "Text 2,2" "Text 2,n"
[3,] "Text 3,1" "Text 3,2" "Text 3,n"
[n,] "Text n,1" "Text n,2" "Text n,n"

I want to concatenate each row together, so I’m left with:

[1,] "Text 1,1 Text 1,2 Text 1,n"
[n,] "Text n,1 Text n,2 Text n,n"

Currently, I’m doing this using a for loop (where textColumns is the cbind() matrix):

concatColumn <- c()
for (i in 1:ncol(textColumns)) concatColumn <- paste(concatColumn,textColumns[,i])

Is there a simpler, more elegant way to do this in R? I’ve been looking around for ways to do this using the paste() command without a for loop, but haven’t been able to find a solution. Thank you in advance for your 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-27T22:14:31+00:00Added an answer on May 27, 2026 at 10:14 pm

    It’s easy with a data.frame,

    m = matrix(letters[1:12], 3, byrow=TRUE)
    do.call(paste, as.data.frame(m, stringsAsFactors=FALSE))
    #[1] "a b c d" "e f g h" "i j k l"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTable containing an arbitrary number of columns and rows which I
So I've got some data. There are entities. Entities have an arbitrary number of
I have a class that spawns an arbitrary number of worker object that compute
I have a model that has an arbitrary number of children entities. For simplicity
Say I have a function that takes an arbitrary number of arguments (the last
Here's my situation. Say I have two columns of data containing different elements. I'd
Suppose I have a text file with data separated by whitespace into columns. I
I have a jlist with an arbitrary number of elements. I would like to
We have a panel which displays a form with an arbitrary number of JTextFields
Here I have an arbitrary IEnumerable<T> . And I'd like to page it using

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.