Witold E Wolski
2014-Jul-04 22:35 UTC
[R] how does a valid subscript can produce an "subscript out of bounds" error?
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>-- Witold Eryk Wolski
Duncan Murdoch
2014-Jul-04 23:50 UTC
[R] how does a valid subscript can produce an "subscript out of bounds" error?
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 >> >How are we supposed to know, since you didn't show us msexp$pepinfo$transition_group_id or the thing it was indexing, msexp$rt ? Please post reproducible examples. Duncan Murdoch
Duncan Murdoch
2014-Jul-05 00:18 UTC
[R] how does a valid subscript can produce an "subscript out of bounds" error?
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