[R] [EXTERNAL] Re: Very strange behavior of 'rep'

Izmirlian, Grant (NIH/NCI) [E] |zm|r||g @end|ng |rom m@||@n|h@gov
Thu Aug 15 22:32:33 CEST 2024


Its where n.per.grp is first calculated. I rounded. Gosh do I feel stupid. Thanks to all who weighed in.
Best Regards,
Grant Izmirlian

________________________________
From: Duncan Murdoch <murdoch.duncan using gmail.com>
Sent: Thursday, August 15, 2024 2:59 PM
To: Izmirlian, Grant (NIH/NCI) [E] <izmirlig using mail.nih.gov>; r-help using r-project.org <r-help using r-project.org>
Subject: [EXTERNAL] Re: [R] Very strange behavior of 'rep'

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://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Freprex.tidyverse.org%2F&data=05%7C02%7Cizmirlig%40mail.nih.gov%7C39d45a0a10d54c446ce808dcbd5c7518%7C14b77578977342d58507251ca2dc2b06%7C0%7C0%7C638593452006022388%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=ZZDiaJt2vEAejBTdsfyxaFtwYs8WBWgeIXVzUvN4%2BHI%3D&reserved=0)</sup<https://reprex.tidyverse.org/>>

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://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C02%7Cizmirlig%40mail.nih.gov%7C39d45a0a10d54c446ce808dcbd5c7518%7C14b77578977342d58507251ca2dc2b06%7C0%7C0%7C638593452006031043%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=LTp63hQ5fGXMg1K3QmkjLq1NRVQv22v7JH5AIn8AFWA%3D&reserved=0<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=05%7C02%7Cizmirlig%40mail.nih.gov%7C39d45a0a10d54c446ce808dcbd5c7518%7C14b77578977342d58507251ca2dc2b06%7C0%7C0%7C638593452006035637%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=OHU65ku0vmIiRInCbI7ep0QDRO5Xytat61CtBkYYMCM%3D&reserved=0<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and are confident the content is safe.


	[[alternative HTML version deleted]]



More information about the R-help mailing list