We present a multi-wavelength study of comet C/2016 R2 (PanSTARRS). This comet was observed on 23-24 January 2018 with the IRAM 30m telescope, and in January to March 2018 with the Nanc{c}ay radio telescope. Visible spectroscopy was performed in December 2017 and February 2018 with small amateur telescopes. We report on measurements of CO, CH3OH, H2CO and HCN production rates, and on the determination of the N2/CO abundance ratio. Several other species, especially OH, were searched for but not detected. The inferred relative abundances, including upper limits for sulfur species, are compared to those measured in other comets at about the same heliocentric distance of about 2.8 AU. The coma composition of comet C/2016 R2 is very different from all other comets observed so far, being rich in N2 and CO and dust poor. This suggests that this comet might belong to a very rare group of comets formed beyond the N2 ice line. Alternatively, comet C/2016 R2 (PanSTARRS) could be the fragment of a large and differentiated transneptunian object, with properties characteristic of volatile-enriched layers.