I think you are somewhere between
Circle 8.2.6 of 'The R Inferno'

http://www.burns-stat.com/documents/books/the-r-inferno/

and the basics of subscripting

http://www.burns-stat.com/documents/tutorials/impatient-r/more-r-subscript/

Pat

On 05/07/2014 15:19, Witold E Wolski wrote:
Thank you. You example helped to FIX IT.

The problem is I guess somehow related to:
class(msexp$pepinfo$transition_group_id)
[1] "factor"

and the whole R type conversion , riddle.

For subscripts my intuition is:  either require integer or do the
"cast" to the rowname type (character).
However, it seems that R somehow prefers to cast factors to integers...

it seems that %in% "casts" both vectors to the same type. But to which one?

Oh, I guess all this is neatly explained in the R standard ... but
websearching for it just returns:
standard deviation


a frustrated R user.

On 5 July 2014 02:18, Duncan Murdoch <murdoch.dun...@gmail.com> wrote:
On 04/07/2014, 6:35 PM, Witold E Wolski wrote:
how does a valid subscript (see first 2 lines) can produce an
"subscript out of bounds" error (see line 4)?


1> sum(!rownames(msexp$rt) %in% msexp$pepinfo$transition_group_id)
[1] 0
2> sum(!msexp$pepinfo$transition_group_id %in% rownames(msexp$rt))
[1] 0
3> class(msexp$rt)
[1] "matrix"
4> msexp$rt = as.matrix(msexp$rt[msexp$pepinfo$transition_group_id,])
Error in msexp$rt[msexp$pepinfo$transition_group_id, ] :
   subscript out of bounds



x <- matrix(1,1,1)
rownames(x) <- colnames(x) <- "23"
23 %in% rownames(x)
[1] TRUE
x[23,]
Error in x[23, ] : subscript out of bounds





--
Patrick Burns
pbu...@pburns.seanet.com
twitter: @burnsstat @portfolioprobe
http://www.portfolioprobe.com/blog
http://www.burns-stat.com
(home of:
 'Impatient R'
 'The R Inferno'
 'Tao Te Programming')

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to