Skip to content

writing data into files whose names are in a vector

6 messages · Raghuraman Ramachandran, Jeff Newmiller

#
You have to wrap the write calls in some kind of loop. For your example, you could use a for loop. If you have multiple rows of one name you might look into the dlply function from the plyr package and use lapply to do the actual write calls. 
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Raghuraman Ramachandran <optionsraghu at gmail.com> wrote:

            
#
you should lapply over a vector of indices (e.g. seq_along(names)) and extract out the subsets of data in your mywrite function before you write them.

Is this homework?
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Raghuraman Ramachandran <optionsraghu at gmail.com> wrote:

            
#
I/O is not greatly improved by vectorization, except that whole files being read or written as units is faster than looping over rows. 
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Raghuraman Ramachandran <optionsraghu at gmail.com> wrote: