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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:35:00+00:00 2026-06-01T12:35:00+00:00

I have big dataset (but the following is small one for example). I can

  • 0

I have big dataset (but the following is small one for example). I can split the dataframe and then I want to output to multiple text file corresponding to lavel used to split.

mydata <- data.frame (var1 = rep(c("k", "l", "c"), each = 5), var2 = rnorm(5), 
      var3 = rnorm(5))
mydata    
   var1       var2       var3
1     k  0.5406022  0.3654706
2     k -0.6356879 -0.9160001
3     k  0.2946240 -0.1072241
4     k -0.2609121  0.1036626
5     k  0.6206579  0.6111655
6     l  0.5406022  0.3654706
7     l -0.6356879 -0.9160001
8     l  0.2946240 -0.1072241
9     l -0.2609121  0.1036626
10    l  0.6206579  0.6111655
11    c  0.5406022  0.3654706
12    c -0.6356879 -0.9160001
13    c  0.2946240 -0.1072241
14    c -0.2609121  0.1036626
15    c  0.6206579  0.6111655

Now split

> spt1 <- split(mydata, mydata$var1) 

> spt1

$c
   var1       var2       var3
11    c  0.5406022  0.3654706
12    c -0.6356879 -0.9160001
13    c  0.2946240 -0.1072241
14    c -0.2609121  0.1036626
15    c  0.6206579  0.6111655

$k
  var1       var2       var3
1    k  0.5406022  0.3654706
2    k -0.6356879 -0.9160001
3    k  0.2946240 -0.1072241
4    k -0.2609121  0.1036626
5    k  0.6206579  0.6111655

$l
   var1       var2       var3
6     l  0.5406022  0.3654706
7     l -0.6356879 -0.9160001
8     l  0.2946240 -0.1072241
9     l -0.2609121  0.1036626
10    l  0.6206579  0.6111655

I want to write.table in name of outputc, outputk, and outputl. Thus output is common prefix followed by name of label for grouping variable.

write.table (spt1) 
  • 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-01T12:35:02+00:00Added an answer on June 1, 2026 at 12:35 pm

    Using lapply over the names of spt1 will allow us to access the dataframes in spt1 and the name that we can use in paste to create our files.

    lapply(names(spt1), function(x){write.table(spt1[[x]], file = paste("output", x, sep = ""))})
    

    You could add a common extension in the paste if you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two big and small dataframes (actually dataset is very very big !).
I have big set of urls and I want to implement an autocompletion. I
I'm pretty new in OOP but have to develop a big project... Just for
I have a DataSet consistint of a big number of tables of information. Is
How much should one DataSet represent? Using the example of an ordering system: While
I have a pretty standard attendance database design, but I want to be alerted
suppose I have one dataset, which is dat1 ID block plot SPID TotHeight 1
I have big issue with url-rewriting for IIS 7.0. I've written simple module for
I have big system that make my system crash hard. When I boot up,
I have big URL list, which I have to download in parallel and check

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.