Hi,

I recommend that you look at the following help pages and experiment a little (maybe create a toy directory with only three or four files with a few lines each):

?files
?dir
?grep
?strsplit

Good luck!
Stephan


jd6688 schrieb:
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 7:19 PM, Nordlund, Dan (DSHS/RDA) [via R] <
ml-node+2280308-38709657-312...@n4.nabble.com<ml-node%2b2280308-38709657-312...@n4.nabble.com>
wrote:

 > -----Original Message-----
From: [hidden 
email]<http://user/SendEmail.jtp?type=node&node=2280308&i=0>[mailto:
r-help-boun...@r-
project.org] On Behalf Of jd6688
Sent: Tuesday, July 06, 2010 3:49 PM
To: [hidden email]<http://user/SendEmail.jtp?type=node&node=2280308&i=1>
Subject: [R] how to define a function in R


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
Don't thank me too soon. :-)  Your question is equivalent to me going to
SAS-L and asking someone to teach me SAS macro language.  You need to
provide more information about what your task actually is.  Where are these
file names that you want to process coming from?  What do you want to do
with them?

The basic approach would be to put the file names in a list and then pass
the list items one at a time to your function.  But how to do that really
depends on what you are trying to do.  You might also read the posting guide
listed at the bottom of every posting.

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


______________________________________________
[hidden email] <http://user/SendEmail.jtp?type=node&node=2280308&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-tp2280290p2280308.html
To unsubscribe from how to define a function in R, click here< (link removed) 
=>.





______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to