Barry Rowlingson <[EMAIL PROTECTED]> writes: > Peter Dalgaard BSA wrote: > > > BTW: If you ever actually need to do something like that, try > > eval(substitute(foo(x)<-10,list(foo=as.name(if (cond) "names" else > > "dim")))) > > please nooooo!!! What's wrong with: > > if(cond){ > names(x) <- 10 > } else { > dim(x) <- 10 > } > > readable, obvious, maintainable, 'portable' for some value of > 'portable'....
Well, there's nothing nonportable with my suggestion either. I thought that "ever actually need to" would suffice to indicate that I wasn't suggesting it as good programming practice. Nothing wrong with your code, except perhaps generality; I was thinking in terms of "function that specifies which replacement function to use", which could involve a larger set of possible functions than names()<- and dim()<-. However, I'd be hard pressed to come up with a case where this would occur in practice. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help