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 Sent from the R help mailing list archive at Nabble.com.
I don't know this for sure, but I would probably read an introduction to R... #copy and paste into R your_fun <- function(argument){argument+1} your_fun(6) On Tue, Jul 6, 2010 at 5:48 PM, jd6688 <jdsignature at gmail.com> 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 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >-- Stephen Sefick ____________________________________ | Auburn University | | Department of Biological Sciences | | 331 Funchess Hall | | Auburn, Alabama | | 36849 | |___________________________________| | sas0025 at auburn.edu | | http://www.auburn.edu/~sas0025 | |___________________________________| Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of jd6688 > Sent: Tuesday, July 06, 2010 3:49 PM > To: r-help at r-project.org > 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 advanceDon'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
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 <jdsignature at gmail.com> 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 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/