[R] Very strange behavior of 'rep'
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Thu Aug 15 20:59:51 CEST 2024
I also can't reproduce this. I'd guess that one of your values of
n.per.grp or n.tt only prints as the values you showed, but is actually
a little smaller. For example,
n.per.grp <- 108 - 1.e-14
n.per.grp
#> [1] 108
n.tt <- 5
n.per.grp*n.tt
#> [1] 540
length(rep(0:1, each=n.per.grp*n.tt))
#> [1] 1078
Duncan Murdoch
<sup>Created on 2024-08-15 with [reprex
v2.1.1](https://reprex.tidyverse.org)</sup>
On 2024-08-15 2:39 p.m., Izmirlian, Grant (NIH/NCI) [E] via R-help wrote:
> \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.
More information about the R-help
mailing list