Skip to content

Commit 09d0a53

Browse files
committed
update vignette about smaller minimum object size
1 parent 4ecec92 commit 09d0a53

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

vignettes/articles/when-to-use.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ obj_size(integer(2000))
4040
obj_size(integer(3000))
4141
```
4242

43-
The vectors above only contained the value `0`. We can replicate that sparsely with `sparse_integer(integer(), integer(), length = 0)`. We see that the size of a 0-length sparse integer vector has a size of `1304 B = 1.3 kB`.
43+
The vectors above only contained the value `0`. We can replicate that sparsely with `sparse_integer(integer(), integer(), length = 0)`. We see that the size of a 0-length sparse integer vector has a size of `888 B`.
4444

4545
```{r}
4646
obj_size(sparse_integer(integer(), integer(), length = 0))
@@ -80,9 +80,9 @@ sparse_x <- sparse_integer(1:200, 1:200, 1000)
8080
obj_size(sparse_x)
8181
```
8282

83-
So it all comes down to a trade-off. Dense integer vectors with a size of 313 or less will be smaller than their sparse counterparts no matter what. Dense integer vector vectors with 314 elements will take up the same amount of memory as their sparse counterpart with no values.
83+
So it all comes down to a trade-off. Dense integer vectors with a size of 210 or less will be smaller than their sparse counterparts no matter what. Dense integer vector vectors with 211 elements will take up the same amount of memory as their sparse counterpart with no values.
8484

85-
From these values we can calculate memory equivalent vectors to determine which would be more efficient, noting that sparse vectors increase in size by twice for each non-default value that their dense counterpart. For a vector of length 1000, the sparse vector will be equivalent in size if it has `343` non-default values. And these values continue to go up.
85+
From these values we can calculate memory equivalent vectors to determine which would be more efficient, noting that sparse vectors increase in size by twice for each non-default value that their dense counterpart. For a vector of length 1000, the sparse vector will be equivalent in size if it has `210` non-default values. And these values continue to go up.
8686

8787
## Conversion speed
8888

0 commit comments

Comments
 (0)