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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:07:01+00:00 2026-05-28T00:07:01+00:00

I want to (as ever) use code that performs better but functions equivalently to

  • 0

I want to (as ever) use code that performs better but functions equivalently to the following:

write.table(results.df[seq(1, ncol(results.df),2)],file="/path/file.txt", row.names=TRUE, sep="\t") 
write.table(results.df[seq(2, ncol(results.df),2)],file="/path/file2.txt",row.names=TRUE, sep="\t")

results.df is a dataframe that looks something thus:

row.names 171401    171401 111201     111201
    1      1     0.8320923  10     0.8320923
    2      2     0.8510621  11     0.8510621
    3      3     0.1009001  12     0.1009001
    4      4     0.9796110  13     0.9796110
    5      5     0.4178686  14     0.4178686
    6      6     0.6570377  15     0.6570377
    7      7     0.3689075  16     0.3689075

There is no consistent patterning in the column headers except that each one is repeated twice consecutively.

I want to create (1) one file with only odd-numbered columns of results.df and (2) another file with only even-numbered columns of results.df. I have one solution above, but was wondering whether there is a better-performing means of achieving the same thing.

IDEA UPDATE: I was thinking there may be some way of excising – deleting it from memory – each processed column rather than just copying it. This way the size of the dataframe progressively decreases and may result in a performance increase???

  • 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-28T00:07:02+00:00Added an answer on May 28, 2026 at 12:07 am

    The code is only slightly shorter but…

    # Instead of 
    results.df[seq(1, ncol(results.df), 2]
    results.df[seq(2, ncol(results.df), 2]
    #you could use 
    results.df[c(T,F)]
    results.df[c(F,T)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not that I would ever need to do this, but I want to understand
I've decided that I don't want to ever use UIPickerView again... it's completely inflexible
Is there ever a circumstance in which I would not want to use the
I want others to be able to create JSON files that my code can
Python has a singleton called NotImplemented . Why would someone want to ever return
I have a textfield where the user can type what ever he want into
If I want to essentially grep every line ever in the repository, is there
Has anyone ever modified the post-new.php file in their WordPress installation? I want to
This is the first time ever I'm using AJAX, and I want to do
i use this code to split a data to make a list with three

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.