# [R], 29 bytes

(Or 22 bytes in R>=4.1 using ‘\’ instead of ‘function)

<!-- language-all: lang-r -->

    function(x)sample(rep(x,x),1)

[Try it online!][TIO-lm3aaf3g]

[R]: https://www.r-project.org/
[TIO-lm3aaf3g]: https://tio.run/##K/qfZvs/rTQvuSQzP0@jQrM4MbcgJ1WjKLVAo0KnQlPHUPN/ma2hlaEBV0liElCiOLGgIKdSAyQCBjpwvZmaaRplmpqa/wE "R – Try It Online"

——

# [R], 25 bytes

(Or 18 bytes in R>=4.1 using ‘\’ instead of ‘function)

<!-- language-all: lang-r -->

    function(x)sample(x,1,,x)

[Try it online!][TIO-lm39gyvx]

[R]: https://www.r-project.org/
[TIO-lm39gyvx]: https://tio.run/##K/qfZvs/rTQvuSQzP0@jQrM4MbcgJ1WjQsdQR6dC83@ZraGVoQFXSWISULA4saAgp1IDJAIGOnB9mZppGmWampr/AQ "R – Try It Online"

The 4th argument of R’s ‘sample’ function is ‘prob’=“a vector of probability weights for obtaining the elements of the vector being sampled”.

This solution may unfortunately fail if the input vector has only 1 element (due to a ‘convenience’ feature of ‘sample’ which changes its behaviour in this case…) We could fix this with ‘function(x)sample(c(x,x),1,,x)’, but this ends-up longer.