[R] getting quotes out of matrix?

Prof Brian D Ripley ripley at stats.ox.ac.uk
Tue Feb 12 18:30:26 CET 2002


On Tue, 12 Feb 2002, Jeff D. Hamann wrote:

> I've trying to check for model bias. It was recommended to me that I should
> break the residuals into n groups and test to see if the mean is different
> from zero. What is the best way to generate the groups. I've generated a
> matrix that contains the residuals and groups, but the values all have
> quotes around them.
>
> 1) how do I get rid of the quotes?
> 2) is this an acceptable method for testing for model bias?
>
> # this is the test code...
> signif <- symnum(fit3sls[[2]]$residuals,
>   corr = FALSE,
>   na = FALSE,
>   cutpoints = c(-5,.1,.2,.3,.4, 5),
>   symbols   =  c("A","B","C","D","E"))
>
> table <- cbind( fit3sls[[2]]$residuals, signif )
> colnames(table) <- c("resid","group")
>
> # prints fine
> print.matrix(table, quote = FALSE, right = TRUE )
>
> #    resid_table <- matrix(table,quote=FALSE )
> # just to look at the data
> #boxplot( resid ~ group, data = resid_table )

1) standard names in R don't have `_' in

2) signif is, I presume, character or factor.  You want a data frame, not a
matrix, and that's what boxplot.formula expects.  cbind creates a character
matrix.  So use, say,

table <- data.frame( resid = fit3sls[[2]]$residuals, signif )

3) Avoid the names of R objects like resid and signif will help not to
confuse your readers, yourself and perhaps R.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list