[R] applying a function to another function

Carlos Cuartas umberto_1010 at yahoo.com
Wed Dec 3 21:51:52 CET 2008


Hello,
I did a function (sec_conop) whose arguments are syndic,
well and wellconop. 
 
sec_conop(syndic='01syndic.txt',well='well-1.csv',wellconop='well-1.dat');closeAllConnections()
 
This function takes “well” and “syndic”, matching between
them and then it does some transformations. The result is exported to
“wellconop”.
I will apply this function to one hundred different “wells”.
Therefore, for each well I use, the “wellconop argument will change too.
For intance if “well” is now well-2.csv, the function will be 

sec_conop(syndic='01syndic.txt',well='well-2.csv',wellconop='well-2.dat');closeAllConnections()
 
I am trying to apply this function automatically to all
“well” I have, but I do not find the way.
The last I tried, for three different “wells”, was :

wells<-data.frame(funct=rep('sec_conop(',3),syndic=c('01syndic.txt','01syndic.txt','01syndic.txt'),well=c('well-1.csv','well-2.csv','well-3-1.csv'),wellconop=c('well-1.dat','well-2.dat','well-3.dat'))
 
funct_3wells<-paste(wells$funct,"'",wells$syndic,"'", ","
,"'", wells$well,"'",
"," , "'" ,wells$wellconop,"'",")",";","closeAllConnections()",sep='')
 
lapply(funct_3wells,as.formula)
 
This way works partially because the results in “wellconop”
are truncated. 
Has anyone any suggestion?

Thanks in advance

Carlos


      


More information about the R-help mailing list