[R] Very strange behavior of 'rep'

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Thu Aug 15 20:51:56 CEST 2024


Às 19:39 de 15/08/2024, Izmirlian, Grant (NIH/NCI) [E] via R-help escreveu:
> \n<<SEND AS PLAIN TEXT!>>\n\n \n<<
> This is very weird. I was running a swarm job on the cluster and it bombed
> only for n.per.grp=108, not for the other values. Even though
> n.per.grp*n.tt is 540, so that the length of the call to 'rep'
> should be 1080, I'm getting a vector of length 1078.
>      n.per.grp <- 108
>      n.tt <- 5
>      n.per.grp*n.tt
>      length(rep(0:1, each=n.per.grp*n.tt))
>      length(rep(0:1, each=108*5))
>>> \n<<Grant Izmirlian grant.izmirlian at nih dot gov>>\n\n\n\n
> --please do not edit the information below--
> 
> R Version:
>   platform = x86_64-pc-linux-gnu
>   arch = x86_64
>   os = linux-gnu
>   system = x86_64, linux-gnu
>   status =
>   major = 4
>   minor = 4.1
>   year = 2024
>   month = 06
>   day = 14
>   svn rev = 86737
>   language = R
>   version.string = R version 4.4.1 (2024-06-14)
>   nickname = Race for Your Life
> 
> Locale:
>   LC_CTYPE=C.UTF-8;LC_NUMERIC=C;LC_TIME=C.UTF-8;LC_COLLATE=C.UTF-8;LC_MONETARY=C.UTF-8;LC_MESSAGES=C.UTF-8;LC_PAPER=C.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C.UTF-8;LC_IDENTIFICATION=C
> 
> Search Path:
>   .GlobalEnv, package:lme4, package:Matrix, package:stats,
>   package:graphics, package:grDevices, package:utils, package:datasets,
>   package:showtext, package:showtextdb, package:sysfonts,
>   package:methods, Autoloads, package:base
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Hello,

I cannot reproduce this behavior.



n.per.grp <- 108
n.tt <- 5
n.per.grp*n.tt
#> [1] 540
length(rep(0:1, each = n.per.grp*n.tt))
#> [1] 1080
length(rep(0:1, each = 108*5))
#> [1] 1080



But my version of R and my OS are different.
(I don't see how the error in the OP can be related to R version or OS.)



R.version
#>                _
#> platform       x86_64-w64-mingw32
#> arch           x86_64
#> os             mingw32
#> crt            ucrt
#> system         x86_64, mingw32
#> status
#> major          4
#> minor          4.1
#> year           2024
#> month          06
#> day            14
#> svn rev        86737
#> language       R
#> version.string R version 4.4.1 (2024-06-14 ucrt)
#> nickname       Race for Your Life



Hope this helps,

Rui Barradas


-- 
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença de vírus.
www.avg.com



More information about the R-help mailing list