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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:20:43+00:00 2026-06-12T05:20:43+00:00

using R, I have to write an output file from a list. So I

  • 0

using R, I have to write an output file from a list. So I think to use a ‘for’ loop to unlist and and write out.

l.spec <- list(a=c(rep("A",10)), b=c(rep("B",4)), c=c(rep("C",6)))
f <- matrix()
for(i in seq_along(l.spec)){
    f <- matrix(unlist(l.spec[i]), byrow=TRUE)
    cat(f, file="output.txt", sep="\n", append=TRUE)
}

Furthermor I need to insert a blank line between each level of the list to obtain an output such as:

A
A
A
A
A
A
A
A
A

B
B
B
B

C
C
C
C
C
C

Do you have any suggestion??

Regards

Riccardo

  • 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-12T05:20:44+00:00Added an answer on June 12, 2026 at 5:20 am

    This seems to do what you want

    lapply(l.spec, function(x) cat(c(x, " "), file = "output.txt", sep = "\n", append = TRUE))

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

Sidebar

Related Questions

I have to write an XML file using java.The contents should be written from
I have been to trying to write some output to a CSV file using
I have to write a biginteger into a text file using the following statement.
Is it possible to have 2 applications write to the same log file using
I have two long list, one from a log file that contains lines formatted
Basically I have 14800x8 matrix that has been extracted from matlab as CSV file
Essentially, I have a Do..While loop going through some lines from a text file.
If I have to write a singleton class in C++ I will be using
I'm using Squirrel SQL with Oracle. I often have to write quick queries for
I am creating graphs using GD::Graph::lines . For option set, I have to write

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.