[R] A printing "macro"

2006-11-13 Thread Murray Jorgensen
I am exploring the result of clustering a large multivariate data set into a number of groups, represented, say, by a factor G. I wrote a function to see how categorical variables vary between groups: > ddisp <- function(dvar) { + csqt <- chisq.test(G,dvar) + print(csqt$statistic) + print(c

Re: [R] A printing "macro"

2006-11-13 Thread Prof Brian Ripley
ddisp <- function(dvar) { yn <- substitute(dvar) csqt <- eval.parent(substitute(chisq.test(G,dvar), list(dvar=yn))) } There are other ways, such as forming the cross-classification table, setting its dimnames and passing that to chisq.test. On Mon, 13 Nov 2006, Murray Jorgens

Re: [R] A printing "macro"

2006-11-13 Thread Murray Jorgensen
Thanks for these suggestions, Professor Ripley. It's interesting that the function parameters in R are not truly "dummy" as they can effect the result of a function. Murray Prof Brian Ripley wrote: > ddisp <- function(dvar) { > yn <- substitute(dvar) > csqt <- eval.parent(substitute(chis