What's going on here: $ R --vanilla --quiet
f <- function(n) rep("x", times = n)
f()
[1] "x" ?
getRversion()
[1] ?4.5.2? /Henrik
4 messages · Henrik Bengtsson, Rui Barradas, Peter Langfelder +1 more
What's going on here: $ R --vanilla --quiet
f <- function(n) rep("x", times = n)
f()
[1] "x" ?
getRversion()
[1] ?4.5.2? /Henrik
?s 06:40 de 11/12/2025, Henrik Bengtsson escreveu:
What's going on here: $ R --vanilla --quiet
f <- function(n) rep("x", times = n)
f()
[1] "x" ?
getRversion()
[1] ?4.5.2? /Henrik
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Hello,
I can reproduce this on Windows.
Microsoft Windows [Version 10.0.22631.5039]
(c) Microsoft Corporation. Todos os direitos reservados.
C:\>R --vanilla --quiet
> f <- function(n) rep("x", times = n)
> f
function(n) rep("x", times = n)
> f()
[1] "x"
> getRversion()
[1] '4.5.2'
> g <- function(n) rep(1, times = n)
> g
function(n) rep(1, times = n)
> g()
[1] 1
> h <- function(n) rep(1, n)
> h
function(n) rep(1, n)
> h()
[1] 1
> i <- function(n) rep(1, each = n)
> i()
[1] 1
> sessionInfo()
R version 4.5.2 (2025-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)
Matrix products: default
LAPACK version 3.12.1
locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8 LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.utf8
time zone: Europe/Lisbon
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.5.2 tools_4.5.2
> q()
Hope this helps,
Rui Barradas
I think it's a bit of a quirk of rep:
rep("x")
[1] "x"
Help of 'rep' does state this:
The default behaviour is as if the call was
rep(x, times = 1, length.out = NA, each = 1)
So it seems to even be documented.
Peter
Peter
On Thu, Dec 11, 2025 at 2:40?PM Henrik Bengtsson
What's going on here: $ R --vanilla --quiet
f <- function(n) rep("x", times = n)
f()
[1] "x" ?
getRversion()
[1] ?4.5.2? /Henrik
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Le 11/12/2025 ? 09:21, Peter Langfelder a ?crit?:
I think it's a bit of a quirk of rep:
rep("x")
[1] "x"
Help of 'rep' does state this:
The default behaviour is as if the call was
rep(x, times = 1, length.out = NA, each = 1)
So it seems to even be documented.
Right. But I think the initial question was rather "why f() does not
complain about missing n?"
It is because 'n' is not used in f() itself, it's just passed through in
his quality of "missing".
If you define f() where 'n' is used in some way, e.g. as follows:
f=function(n) rep("x", times=n+0L)
then it complains:
f()
Error in f() (from #1) : argument "n" is missing, with no default
Serguei.
Peter Peter On Thu, Dec 11, 2025 at 2:40?PM Henrik Bengtsson <henrik.bengtsson at gmail.com> wrote:
What's going on here: $ R --vanilla --quiet
f <- function(n) rep("x", times = n)
f()
[1] "x" ?
getRversion()
[1] ?4.5.2? /Henrik
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Serguei Sokol Ingenieur de recherche INRAE Cellule Math?matiques TBI, INSA/INRAE UMR 792, INSA/CNRS UMR 5504 135 Avenue de Rangueil 31077 Toulouse Cedex 04 tel: +33 5 61 55 98 49 email: sokol at insa-toulouse.fr https://www.toulouse-biotechnology-institute.fr/en/plateformes-plateaux/cellule-mathematiques/