[R] function output with for loop and if statement

Richard M. Heiberger rmh at temple.edu
Thu Apr 23 22:32:06 CEST 2009


tmp.out.sort <- tmp.out[, order(names(tmp.out))]

tmp.out.sort <- tmp.out[, order(names(tmp.out)), drop=FALSE]

>From your description of misbehavior with a single column,
I think the drop=FALSE argument will provide the protection you need.
Then you will not need the if clause.

See

?`[.data.frame`
for the story and examples.


Rich




More information about the R-help mailing list