[R] I don't understand this
Barry Rowlingson
B.Rowlingson at lancaster.ac.uk
Tue Sep 2 18:00:35 CEST 2003
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'....
although I'd also want to add a comment explaining why you are
conditionally setting either the names or the dimension of 'x' to 10....
Baz
More information about the R-help
mailing list