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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:28:55+00:00 2026-06-10T05:28:55+00:00

I have a very large data set, and I have already split it into

  • 0

I have a very large data set, and I have already split it into 50 pieces
So basically the file looks like:
file1
file2
file3
.
.
.
file50 (data frames)

file_total <- c(file1,...,file50)  

I know this will combine it into a list, but I can’t use rbind since the whole all data is huge and the plyr library just takes forever to run

And in each of the files, I have to split them based on 1 factor, name it “id”, then be able to write each of the id subsets into a .csv file

so far, my codes are:

d_split <- split(file1, file1[1])

library(plry)
id <- unlist(lapply(d_split,"[",1,1)) # this returns the unique id

for (j in seq_along(id))
{ 
    write.csv(d_split[[j]], file=paste(id[j], "csv", sep="."))
}

this works!!

but It doesn’t work when I try to put it into a another for loop:

for (i in file_total)
{
    d_split <- split(i, i[1])
    id <- unlist(lapply(d_split,"[",1,1)) 
    for (j in seq_along(id))
    {
        write.csv(d_split[[j]], file=paste(id[j], "csv", sep="."))
    }
}

It returns to the following error messages:

Error in FUN(X[[1L]], ...) : incorrect number of dimensions

I meant I could done it manually by copy and pasting 50 files into the code, but was just wondering if anyone could fix my code, so that one click will get it solved.

  • 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-10T05:28:56+00:00Added an answer on June 10, 2026 at 5:28 am

    The problem occurs based on how you combine the data. Instead of combining them with c, make them into a list:

    file_total <- list(file1,...,file50) 
    

    At this point, doing i in file_total will iterate as you want it to.

    As an explanation: using c with data frames (as I’m assuming file1 and file2 are) will actually turn them into a list of vectors rather than a list of data frames. For instance:

    file1 = data.frame(x=1:20)
    file2 = data.frame(y=20:40)
    file_total = c(file1, file2)
    # file_total will be:
    # $x
    #  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
    #
    # $y
    #  [1] 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    

    Thus, iterating over them will actually iterate over the individual columns as vectors. However, using list to combine them will let you iterate over the data frames themselves:

    > list(file1, file2)
    [[1]]
        x
    1   1
    2   2
    3   3
    4   4
    5   5
    6   6
    7   7
    8   8
    9   9
    10 10
    11 11
    12 12
    13 13
    14 14
    15 15
    16 16
    17 17
    18 18
    19 19
    20 20
    
    [[2]]
        y
    1  20
    2  21
    3  22
    4  23
    5  24
    6  25
    7  26
    8  27
    9  28
    10 29
    11 30
    12 31
    13 32
    14 33
    15 34
    16 35
    17 36
    18 37
    19 38
    20 39
    21 40
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very large data set that I'd like to craft into a
I have a very large XML file which has like 40000 data, and when
I have a very large possible data set that I am trying to visualize
I have a very large data file with around 60000 rows. I need to
I have a very large set of data (~3 million records) which needs to
I have a very large data set that I'm trying to find the smallest
I've got a very large xml data set that is structured like the following:
I have a query that returns a very large data set. I cannot copy
So I have a very large project which when run prints a data set
I have a webpage that displays a very large list of data. Since this

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.