gzip              package:Rcompression              R Documentation

_P_e_r_f_o_r_m _i_n-_m_e_m_o_r_y _g_z_i_p _c_o_m_p_r_e_s_s_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     This function compresses the content  using the GZIP compression
     format and returns the resulting compressed content.  It does this
     within memory rather than writing to file. This content can then
     be passed to other functions to be used in other contexts, e.g.
     sent to a Web server as part of a request, inserted into an HTML
     document via base64 encoding.

_U_s_a_g_e:

     gzip(content, level = 1, windowBits = (15 + 16), memLevel = 9, strategy = 0L, 
           size = length(content) * 1.01 + 12)

_A_r_g_u_m_e_n_t_s:

 content: the content to be compressed. This should be either a 'raw'
          vector or a character vector which will be collapsed to a
          single string. 

   level: the compression level, a number between 1 and 9

windowBits: integer between 24 and 31. Larger values result in better
          compression at the expense of memory usage. This is a value
          between 8 and 15 with 16 added on to cause GZIP compression
          to be used. 

memLevel: a value between 1 and 9 that controls the tradeoff of memory
          and speed  used in the  process of compression. Larger values
          use more memory with better speed.

strategy: an integer, this should be 0 for the default strategy.
          filter, huffman and rle strategies are also available.

    size: a number, the size to use as the best guess for the size of
          the result. The output buffer will grow as necessary, but
          this provides an opportunity to  specify an initial guees. 

_D_e_t_a_i_l_s:

     This uses the zlib library.

_V_a_l_u_e:

     A 'raw' object containing the compressed information. Note that
     this cannot currently be uncompressed with the 'gunzip' function
     but can be decompressed with the gzip application.

_A_u_t_h_o_r(_s):

     Duncan Temple Lang

_R_e_f_e_r_e_n_c_e_s:

     <URL: http://www.gzip.org>

_S_e_e _A_l_s_o:

     'compress'

_E_x_a_m_p_l_e_s:

     txt = paste(rep("This is a string", 40), collapse = "\n")
     v = gzip(txt)
     f = tempfile()
     writeBin(v, f)
     readLines(gzfile(f))

     dev = paste(tempfile(), "pdf", sep = ".")
     pdf(dev)
     plot(1:10)
     dev.off()
     vals = readBinaryFile(dev)
     writeBin(gzip(vals), paste(dev, "gz", sep = "."))

