[R] Parsing question, partly comma separated partly underscore separated string

Gabor Grothendieck ggrothendieck at gmail.com
Tue Mar 8 13:06:55 CET 2011


On Mon, Mar 7, 2011 at 10:45 PM, Eric Fail <eric.fail at gmx.com> wrote:
> Thanks to Gabor Grothendieck and Dennis Murphy I can now solve first
> part of my problem and already impress my colleagues with the
> R-program below (I know it could be written in a smarter way, but I am
> learning). It reads my partly comma separated partly underscore
> separated string and cleans it up in a very need way.
>
> Regardless of my inability to write tight code I moved on to the
> second part of my quest, to put it all in to a loop to be able to loop
> over my approximately 100 .txt files in /usr2/username/data/ I got
> started with list.files() and my loop is more or less working, but I
> got stuck on the last cbind part.
>
> Is there a friendly R-hacker out there that would be willing to take a
> look at my loop below*2?
>

Create a function Read(filename) which returns the data frame for the
indicated file and then do this where fname is the vector of
filenames:

   do.call("rbind", lapply(fname, Read))



More information about the R-help mailing list