Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. ## Create 2 two-million length vectors, one character and one factor
  2. animalsChar <- c(rep("giraffe", 1e6), rep("pygmy chimpanzee", 1e6))
  3. animalsFac <- factor(animalsChar)
  4.  
  5. ## Save them to two ".Rdata" files
  6. charFile <- "char.Rdata"
  7. facFile <- "fac.Rdata"
  8. save(animalsChar, file = "char.Rdata")
  9. save(animalsFac, file = "fac.Rdata")
  10.  
  11. ## Compare the sizes of the two files
  12. file.info("char.Rdata", "fac.Rdata")["size"]
  13. # size
  14. # char.Rdata 87390
  15. # fac.Rdata 7921
  16.  
  17.  
  18. ## Clean up
  19. unlink(c("char.Rdata", "fac.Rdata"))
  20.  
  21. > x <- rep(c("x","y","z"),1e6)
  22. > print(object.size(x),units="Mb")
  23. 22.9 Mb
  24. > print(object.size(factor(x)),units="Mb")
  25. 11.4 Mb
  26. > version
  27. _
  28. platform x86_64-pc-linux-gnu
  29. arch x86_64
  30. os linux-gnu
  31. system x86_64, linux-gnu
  32. status
  33. major 3
  34. minor 1.3
  35. year 2015
  36. month 03
  37. day 09
  38. svn rev 67962
  39. language R
  40. version.string R version 3.1.3 (2015-03-09)
  41. nickname Smooth Sidewalk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement