[R] trying to build matrix for tests...

Jonathan Rougier J.C.Rougier at durham.ac.uk
Fri Mar 1 09:54:13 CET 2002


Hi Jeff,

I think this is what you want ...

> resid <- rnorm(30) # some residuals
> signif <- symnum(resid, corr = FALSE, na = FALSE,
  cutpoints = c(-5,.1,.2,.3,.4, 5), symbols = LETTERS[1:5])
> rt <- data.frame(resid, signif = ordered(signif, levels = LETTERS[1:5]))
> boxplot(resid ~ signif, data = rt)

If you want to include the result from symnum directly into a dataframe
then you could use the I() function, ie as

> rt <- data.frame(resid, signif = I(signif))

but the boxplot won't work in this case.

Cheers, Jonathan.

"Jeff D. Hamann" wrote:
> 
> Okay, I stumped. I'm trying to build a matrix or data.frame that consists of
> values by group. For example,
> 
> resid, group
> 
> 574 0.536196370873122    E
> 575 0.93191093696265     E
> 576 -1.27116094894117    A
> 577 -1.05159666055027    A
> 578 0.398273458301184    D
> 579 0.586373126102573    E
> 580 0.806575304513802    E
> 581 0.897258393118338    E
> 582 0.342393324256838    D
> 583 0.781245511773227    E
> 
> I can get the values without the quotes, but when I try to use the matrix I
> get errors like,
> 
> Error in "colnames<-"(*tmp*, value = c("resid", "group")) :
>         attempt to set an attribute on NULL
> 
> and
> 
> > attach( rt )
> Error in attach(rt) : attach only works for lists and data frames
> 
> the code that I use to build the matrix is :
> 
> # break up the classes into cats and test for departure from zero
> signif <- symnum(fit3sls[[2]]$residuals,
>   corr = FALSE,
>   na = FALSE,
>   cutpoints = c(-5,.1,.2,.3,.4, 5),
>   symbols   =  c("A","B","C","D","E"))
> 
> rt <- noquote( cbind( fit3sls[[2]]$residuals, signif ) )
> colnames(table) <- c("resid","group")
> 
> boxplot( resid ~ signif, data = rt )
> 
> which doesn't work. What do I need to do when building the matrix to make it
> usable as a data set.
> 
> Thanks,
> jeff.
> 
> Jeff D. Hamann
> Hamann, Donald & Associates, Inc.
> PO Box 1421
> Corvallis, Oregon USA 97339-1421
> Bus. 541-753-7333
> Cell. 541-740-5988
> jeff_hamann at hamanndonald.com
> www.hamanndonald.com
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
Jonathan Rougier                       Science Laboratories
Department of Mathematical Sciences    South Road
University of Durham                   Durham DH1 3LE
tel: +44 (0)191 374 2361, fax: +44 (0)191 374 7388
http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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