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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:05:22+00:00 2026-05-19T04:05:22+00:00

I have three equal-sized data frames that I want to merge in a particular

  • 0

I have three equal-sized data frames that I want to merge in a particular order so that I can then use write.table to make a formatted text file for use in another program.

I want this:

dataframeA_col1 dataframeB_col1 dataframeC_col1 dataframeA_col2 dataframeB_col2 dataframeC_col2 etc…

Not this:
dataframeA_col1 dataframeA_col2 dataframeB_col1 dataframeB_col2

I started to write the loop below which works but only gives me the first 3 columns. How can I fix this loop, or is there a better approach?

temp <- c()
for(i in length(dataframeA)){
temp <- cbind(temp, dataframeA[,i], dataframeB[,i], dataframeC[,i])
i <- i+1
}
  • 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-19T04:05:22+00:00Added an answer on May 19, 2026 at 4:05 am

    Sure, here’s a loop-less way:

    dfA <- data.frame(col1 = 1:4, col2 = 1:4, col3 = 1:4)
    dfB <- dfA
    dfC <- dfA
    colSeq <- c ( matrix(1 : (3*ncol(dfA)), 3, ncol(dfA), byrow = TRUE) )
    

    where colSeq is your desired column sequence:

    > colSeq
    [1] 1 4 7 2 5 8 3 6 9 
    

    and now use this colSeq to rearrange the columns of cbind(dfA,dfB,dfC):

    > cbind(A = dfA, B = dfB, C = dfC)[, colSeq ]
      A.col1 B.col1 C.col1 A.col2 B.col2 C.col2 A.col3 B.col3 C.col3
    1      1      1      1      1      1      1      1      1      1
    2      2      2      2      2      2      2      2      2      2
    3      3      3      3      3      3      3      3      3      3
    4      4      4      4      4      4      4      4      4      4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My only problem is making them line up three-across and have equal spacing. Apparently,
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page
I have three unordered lists that have been created as Scriptaculous Sortables so that
I have three values I need to align in a dropdown box. How can
I have data that is mostly centered in a small range (1-10) but there
If all tables I want to delete from have the column gamer_id can i
I have wrote a simple client that use TcpClient in dotnet to communicate. In
If I have an arbitrary sized grid of equal sized squares (with no spacing
I have three models: class ReleaseItem < ActiveRecord::Base has_many :pack_release_items has_one :pack, :through =>

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.