The relative modification of the prompt psi(2S) and J/psi yields from pp to PbPb collisions, at the center-of- mass energy of 5.02 TeV per nucleon pair, is presented. The analysis is based on pp and PbPb data samples collected by the CMS experiment at the LHC in 2015, corresponding to integrated luminosities of 28.0 pb(-1) and 464 mu b(-1), respectively. The double ratio of measured yields of prompt charmonia reconstructed through their decays into muon pairs,(N-psi(2S)/N J/psi )(PbPb)/(N-psi((2S))/N (J/psi) )(pp),is determined as a function of PbPb collision centrality and charmonium transverse momentum p(T), in two kinematic intervals: broken vertical bar y vertical bar < 1.6 covering 6.5 < pT < 30 GeV/c and 1.6 < broken vertical bar y vertical bar < 2.4 covering 3 < pT < 30 GeV/c. The centrality-integrated double ratios are 0.36 +/- 0.08(stat) +/- 0.05(syst) in the first interval and 0.24 +/- 0.22(stat) +/- 0.09(syst) in the second. The double ratio is lower than unity in all the measured bins, suggesting that the psi(2S) yield is more suppressed than the J/psi yield in the explored phase space.