[R] how does a valid subscript can produce an "subscript out of bounds" error?

Duncan Murdoch murdoch.duncan at gmail.com
Sat Jul 5 02:18:08 CEST 2014


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



More information about the R-help mailing list