# How do I use compressed data with R?

R supports two primary ways of accessing compressed data. This allows you to keep your data files on disk compressed saving space, and often time (since the file I/O saved by compression is often more expensive than the cpu cycles it uses).

If you are storing your data in native format, simply use the compress option of save:

tst.df=as.data.frame(cbind(1:10,2:11)) # just some testing data save(tst.df,file="test.Rbin", compress=T) # save a compressed R file

load("test.Rbin")
write.table(tst.df,gzfile("test.dat.gz")) # write a compressed file read.table(gzfile("test.dat.gz"),row.names=1)# read it back in