开发者

What is R table function max size?

I'm using the R table() function,开发者_运维知识库 it only gives me 4222 rows, is there some kind of configuration to accept more rows?


table function is not limited to 4222 rows. Most likely, it is the printing limit that gives you the trouble.

Try:

options(max.print = 20000)

also, check the "real" number of rows:

tbl <- table(state.division, state.region)
nrow(tbl)


Nothing wrong with larger tables? What gave you that impression?

> set.seed(123)
> fac <- factor(sample(10000, 10000, rep = TRUE))
> fac2 <- factor(sample(10000, 10000, rep = TRUE))
> tab <- table(fac, fac2)
> str(tab)
 'table' int [1:6282, 1:6279] 0 0 0 0 0 0 0 0 0 0 ...
 - attr(*, "dimnames")=List of 2
  ..$ fac : chr [1:6282] "1" "5" "7" "9" ...
  ..$ fac2: chr [1:6279] "1" "2" "3" "4" ...

Printing tab will cause problems - it takes a while to generate and then you'll get this message:

 [ reached getOption("max.print") -- omitted 6267 rows ]]

You can alter that by changing options(max.print = XXXXX) where XXXXX is some large number. But I don't see what is gained by printing such a large table? If you were trying to do this to see if the correct table had been produced, size-wise, then

> dim(tab)
[1] 6282 6279
> str(tab)
 'table' int [1:6282, 1:6279] 0 0 0 0 0 0 0 0 0 0 ...
 - attr(*, "dimnames")=List of 2
  ..$ fac : chr [1:6282] "1" "5" "7" "9" ...
  ..$ fac2: chr [1:6279] "1" "2" "3" "4" ...

help with that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜