zlib provides access to the functions in the zlib C library, using Rcpp.
This is a basic example which shows you how to solve a common problem:
library(zlib)
input_text <- "Some text to compress"
compressed_text <- zlib::compress(charToRaw(input_text))
decompressed_text <- rawToChar(zlib::decompress(compressed_text))
identical(input_text, decompressed_text)
#> [1] TRUE