Subscript out of range error in R -



Subscript out of range error in R -

i new r, , encountered unusual error. have table this:

dat<-c(1,2,3,4,4,53,62,345,3,4,346,23,34,52,34,2345,23,4) dat.table<-table(dat)

this creates table , specific column table. when seek dat.table[[3]] gives me 2 true occurrence of 3 in vector. when seek dat.table[[2345]], although 2345 nowadays in rownames(dat.table), gives next error:

error in b[[2345]] : subscript out of bounds

this basic question unusual why r behaves differently different rownames!! appreciate help.

by chance, occurrence of "3" stored in 3rd column of dat.table.

let's seek illustration (2 zeros added):

dat <- c(0,1,2,3,4,4,53,62,345,3,4,346,23,34,0,52,34,2345,23,4) dat.table[[3]] [1] 1

oops, wrong value. now, let's seek with

dat.table[["3"]] [1] 2

correct

"2345" character, name of column. when type dat.table[[2345]], seek access 2345th element, doesn't exist. need specify name of column

dat <- c(1,2,3,4,4,53,62,345,3,4,346,23,34,52,34,2345,23,4) dat.table <- table(dat) dat.table[["2345"]] [1] 1

r

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -