I've already given you an example (ecdf). You can look at the polynom package as well. Try:
install.packages("polynom") library(polynom) as.function.polynomial Here's one trivial example: > f <- function(type) { g <- if (type == 1) cos else sin; g; } > myfun1 <- f(1) > myfun2 <- f(2) > myfun1(pi) [1] -1 > myfun2(pi) [1] 1.224606e-16 As I said, reading the R Language Definition manual or S Programming helps a lot. Andy > From: Hu Chen > > Sorry for my confusing expression. > I need create some new temp functions after the package is loaded. And > these new functions should be visible and usable. > > Functions could be returned as a object, as Liaw mentioned. However I > can't find some examples in R-intro. I also want to know whether > functions returned by their "father function" could be called outside. > > Thank u all. > > > On 6/7/05, Uwe Ligges <[EMAIL PROTECTED]> wrote: > > Hu Chen wrote: > > > > > I got a dirty way to solve this. > > > write a temp .R source file including these new functions, then > > > > > >>source(this_temp_file) > > > > Don't know if you really have to do it that way, but I also > really don't > > understand what you are going to do... > > > > > > > but I don't know if there are some temp directory for R > to store temp files? > > > > See ?tempfile and ?tempdir > > > > Uwe Ligges > > > > > On 6/7/05, Hu Chen <[EMAIL PROTECTED]> wrote: > > > > > >>hi R folks, > > >>I need read a file from hardisk or www web. Then I need > to define some > > >>new functions according to the contents of the read file. > > >>For example, i need write a package name "mypackage" like this: > > >> > > >>>library(mypackage) > > >>>read(some_file_on_web) #to see its content, suppose it contains: > > >> > > >>eat.drink.sleep > > >>then 3 new functions need to be created and usable. > > >>the problem is, how could I create functions after executing > > >>">library(mypackage)" and make these new functions > visible and usable > > >>immediately? > > >> > > >>Any information are appreciated. forgive me if this > question is very > > >>stupid. but I really need help. > > >>Thank you all. > > >> > > > > > > > > > ______________________________________________ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > > > > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html