简体   繁体   中英

In R how do I export one large vector into several .txt files

I have a vector with 32 elements (each element is a long list, going to be a batch file)

I would like to export it into 32 different txt files, but i dont know how to. It would be also important, that each txt file should start with: "#!/bin/bash "

some more details: the whole vector is made up by lines like this:

"./mhc_II_binding.py IEDB_recommendedHLA-DPA1*01/DPB1*04:0140715.GL89783GL884983.pep.fsa>results/result_HLA-DPA1*01/DPB1*04:01.txt"

I had cca. 55000 lines, i grouped the vector into another one, now it has 32 elements, each element is made up by cca. 1700 lines. I would like to have 32 .txt files, each file containig 1 element(so 1700 lines) of my vector. And each file should start with "#!/bin/bash "

This should get you to the saving point.

for(i in seq(1,length(sample_vector),1700)) {
    if(i+1700>=length(sample_vector)) {
        #Vector access for this sequence is as follows:
        #sample_vector[i:length(sample_vector)]
    } else {
        #Vector access for this sequence is as follows:
        #sample_vector[i:(i+1699)]
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM