
Hi Joshua:

Here are what i am going to accomplish:

I have 400 files named as xxx.txt. the content of the file looks like the
following:

    name    count

1. aaa     100
2. bbb    2000
3. ccc    300
4. ddd   3000

........
more that 1000 rows in each files.

these are the areas i need help:
1. how can i only read in the files with the string patterns ggg or fff as
part of the file names?
  for instance, I only need the file names with the ggg or fff in it
     xxxxx_ggg_yyyyy_1.txt
     yyyy_fff_yyyy_xxx.txt

    i don't need to read in the files, such as xxxx_aaa_yyyy.txt

2.how cam rename the files:

  for instance: xxxxx_ggg_yyyyy_1.txt======>changed to ggg1a.txt


3.after the files read in, how can i only keep the rows with the aaa and
bbb, everything elses show be removed from the files, but the files still
remain the same file name?

   for instance, in the xxxxx_ggg_yyyyy_1.txt file, it shouls looks like:
 name    count

1. aaa    100
2. bbb    2000
3. aaa    300
4. bbb    400


Thanks so lot, I am very new to R, I am looking forward to any helps from
you.


On Tue, Jul 6, 2010 at 9:23 PM, Joshua Wiley-2 [via R] <
ml-node+2280373-448579502-312346@n4.nabble.com<ml-node%2B2280373-448579502-312346@n4.nabble.com>
> wrote:

> Hello,
>
> As others have said, its hard to give specific advice without specific
> needs, but that's okay; I made up some examples needs and some (rather
> silly) code that might handle it.  Depending what you need to do, it
> may help you get started.  I tried to explicitly name all the
> arguments in any functions I used.
>
> When I make gmail use basic text format instead of html, code is sent
> poorly, so you can trundle off here to see the example, if you like.
>
> http://gist.github.com/466164
>
> Cheers,
>
> Josh
>
> On Tue, Jul 6, 2010 at 3:48 PM, jd6688 <[hidden email]<http://user/SendEmail.jtp?type=node&node=2280373&i=0>>
> wrote:
>
> >
> > 1. how to write a R script?
> > 2.How to write a SAS like macro/generic process to process multiple files
> by
> > using the same funstion in R?
> >
> > Thanks in advance
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/how-to-define-a-function-in-R-tp2280290p2280290.html<http://r.789695.n4.nabble.com/how-to-define-a-function-in-R-tp2280290p2280290.html?by-user=t>
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > ______________________________________________
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=2280373&i=1>mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Joshua Wiley
> Ph.D. Student, Health Psychology
> University of California, Los Angeles
> http://www.joshuawiley.com/
>
> ______________________________________________
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2280373&i=2>mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
>
> ------------------------------
> View message @
> http://r.789695.n4.nabble.com/how-to-define-a-function-in-R-tp2280290p2280373.html
> To unsubscribe from how to define a function in R, click here< (link removed) =>.
>
>
>

-- 
View this message in context: http://r.789695.n4.nabble.com/how-to-define-a-function-in-R-tp2280290p2281376.html
Sent from the R help mailing list archive at Nabble.com.

	[[alternative HTML version deleted]]

