Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Create 2 two-million length vectors, one character and one factor
- animalsChar <- c(rep("giraffe", 1e6), rep("pygmy chimpanzee", 1e6))
- animalsFac <- factor(animalsChar)
- ## Save them to two ".Rdata" files
- charFile <- "char.Rdata"
- facFile <- "fac.Rdata"
- save(animalsChar, file = "char.Rdata")
- save(animalsFac, file = "fac.Rdata")
- ## Compare the sizes of the two files
- file.info("char.Rdata", "fac.Rdata")["size"]
- # size
- # char.Rdata 87390
- # fac.Rdata 7921
- ## Clean up
- unlink(c("char.Rdata", "fac.Rdata"))
- > x <- rep(c("x","y","z"),1e6)
- > print(object.size(x),units="Mb")
- 22.9 Mb
- > print(object.size(factor(x)),units="Mb")
- 11.4 Mb
- > version
- _
- platform x86_64-pc-linux-gnu
- arch x86_64
- os linux-gnu
- system x86_64, linux-gnu
- status
- major 3
- minor 1.3
- year 2015
- month 03
- day 09
- svn rev 67962
- language R
- version.string R version 3.1.3 (2015-03-09)
- nickname Smooth Sidewalk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement