  A measurement of the ratio of branching fractions of the decays $B^+\to
K^+\mu^+\mu^-$ and $B^+\to K^+e^+e^-$ is presented. The proton-proton collision
data used correspond to an integrated luminosity of $5.0\,$fb$^{-1}$ recorded
with the LHCb experiment at centre-of-mass energies of $7$, $8$ and $13\,$TeV.
For the dilepton mass-squared range $1.1 < q^2 < 6.0\,$GeV$^2\!/c^4$ the ratio
of branching fractions is measured to be $R_K =
{0.846\,^{+\,0.060}_{-\,0.054}\,^{+\,0.016}_{-\,0.014}}$, where the first
uncertainty is statistical and the second systematic. This is the most precise
measurement of $R_K$ to date and is compatible with the Standard Model at the
level of 2.5 standard deviations.
