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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:54:33+00:00 2026-05-17T14:54:33+00:00

I have a file where a data structure containing 6 columns is stored side

  • 0

I have a file where a data structure containing 6 columns is stored side by side. That means I have n times 6 columns stored in a flat file.
Basically, I want to rearrange the data in a form that I only have a data.frame containing 6 columns but appending all the data from the file to the end of the first 6 columns.

Row 1V1 1V2 1V3 1V4 1V5 1V6 2V1 2V2 2V3 2V4 2V5 2V6 3V1...  
1  
2

The result should look like that moving data from 2V1-2V6 to the end of 1V1-1V6

Row V1 V2 V3 V4 V5 V6   
1-1  
1-2  
2-1  
2-2

I looked up some code snippets and could load the data into a data frame with all the vectors. Then I tried to create n dataframes containing always the repeating data structures. Then I tried to combine the single dataframes to a final one but it does not work.

df<-read.table("test.txt",header = FALSE, sep = ";", skip = 2)
columnmax=as.integer(ncol(df)/6)
dfnew <- vector(mode="list",length=columnmax)
for ( i in 1:columnmax) {
 start<-((i-1)*6+1)
 end<-(i*6)
 dfnew[[i]]<-df[,start:end]
}
y <- do.call(rbind, dfnew)

RESULT:

Error in match.names(clabs, names(xi)) : 
  names do not match previous names

I used the list mode because I didnt get it working to separate the dataframe otherwise.
But it seems now to me that it makes the rbind to a problem because the “columnnames” are not identically.
I havent not even an idea how to change the column names because its not a matrix in R termini but a list.
I am sure there must be a much simpler way to do what I want but I am just beginning in R and not familiar with the many different concepts of data types.

EDIT: DATA

structure(list(V1 = NA, V2 = NA, V3 = NA, V4 = NA, V5 = NA, V6 = NA, 
    V7 = NA, V8 = NA, V9 = NA, V10 = NA, V11 = NA, V12 = NA, 
    V13 = structure(1L, .Label = "1,20101E+27", class = "factor"), 
    V14 = structure(1L, .Label = "05.07.2010 14:50", class = "factor"), 
    V15 = structure(1L, .Label = "ADMINISTRATOR", class = "factor"), 
    V16 = 1L, V17 = NA, V18 = NA, V19 = structure(1L, .Label = "1,20101E+27", class = "factor"), 
    V20 = structure(1L, .Label = "05.07.2010 14:50", class = "factor"), 
    V21 = structure(1L, .Label = "ADMINISTRATOR", class = "factor"), 
    V22 = 1L, V23 = NA, V24 = NA, V25 = structure(1L, .Label = "1,20101E+27", class = "factor"), 
    V26 = structure(1L, .Label = "05.07.2010 14:50", class = "factor"), 
    V27 = structure(1L, .Label = "ADMINISTRATOR", class = "factor"), 
    V28 = 1L, V29 = NA, V30 = NA, V31 = structure(1L, .Label = "1,20101E+27", class = "factor"), 
    V32 = structure(1L, .Label = "05.07.2010 14:50", class = "factor"), 
    V33 = structure(1L, .Label = "ADMINISTRATOR", class = "factor"), 
    V34 = 1L, V35 = NA, V36 = NA, V37 = NA, V38 = NA, V39 = NA, 
    V40 = NA, V41 = NA, V42 = NA, V43 = NA, V44 = NA, V45 = NA, 
    V46 = NA, V47 = NA, V48 = NA, V49 = NA, V50 = NA, V51 = NA, 
    V52 = NA, V53 = NA, V54 = NA, V55 = NA, V56 = NA), .Names = c("V1", 
"V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10", "V11", 
"V12", "V13", "V14", "V15", "V16", "V17", "V18", "V19", "V20", 
"V21", "V22", "V23", "V24", "V25", "V26", "V27", "V28", "V29", 
"V30", "V31", "V32", "V33", "V34", "V35", "V36", "V37", "V38", 
"V39", "V40", "V41", "V42", "V43", "V44", "V45", "V46", "V47", 
"V48", "V49", "V50", "V51", "V52", "V53", "V54", "V55", "V56"
), row.names = 1L, class = "data.frame")
  • 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-17T14:54:34+00:00Added an answer on May 17, 2026 at 2:54 pm

    Try:

    x1 <- seq(from=1, to=ncol(df)-1, by=6)
    x2 <- seq(from=6, to=ncol(df), by=6)
    
    dfnew <- data.frame("V1"=0,"V2"=0,"V3"=0,"V4"=0,"V5"=0,"V6"=0)
    
    for(x in 1:(ncol(df)/6)) {
    tmpdf <- df[x1[x]:x2[x]]
    colnames(tmpdf) <- colnames(dfnew)
    dfnew <- rbind(dfnew,tmpdf)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV data file with rows that may have lots of columns
I have a file of about 30000 lines of data that I want to
I have a data structure representing a CSV file containing thousands of config settings.
I have an xml file providing data for a datagrid in Flex 2 that
Suppose I have a text file with data separated by whitespace into columns. I
I have a CSV of file of data that I can load in R
I have a file which is an XML representation of some data that is
There is a data file and some image files that I have to download
I have a file with data listed as follows: 0, 2, 10 10, 8,
I have a file in the following format: Data Data Data [Start] Data I

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.