[R] Redefining the for loop
ast_shopping at gmx.de
ast_shopping at gmx.de
Sun Jun 22 21:21:43 CEST 2008
Hi,
I have the following problem:
I want to redefine the for loop (or define a similar statement) to change its behavior under some circumstances. So, I would like sthg. like
"For" = function ( var, vec, statement ) {
if ( ... ) {
/* my implementation of for */
}
else {
/* call R's for loop */
}
}
I tried to manipulate the elements of the list one gets by
e = quote( for ( i in (1:10) ) print("*") )
That means, storing the variable in e[[2]] (my trials didn't work), and the statement in e[[4]], but I failed.
How can one do this in R? It would be best, if I could redefine "for" directly, so that one can use the same syntax, i.e., with the statement after the function call.
Can somebody help me?
Thanks!
{
--
Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx
More information about the R-help
mailing list