[R] Very strange behavior of 'rep'

2024-08-15 Thread Izmirlian, Grant (NIH/NCI) [E] via R-help
\n<>\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 <-

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

2024-08-15 Thread Rui Barradas
Às 19:39 de 15/08/2024, Izmirlian, Grant (NIH/NCI) [E] via R-help escreveu: \n<>\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

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

2024-08-15 Thread Duncan Murdoch
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)) #>

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

2024-08-15 Thread Izmirlian, Grant (NIH/NCI) [E] via R-help
Ok � to be fair, it looks like I need to load everything and reproduce exactly as its occuring. I suspect its a weird memory hole in one of the loaded packages. Here � this should do it. "%,%" <- paste0 "factorial.design" <- function(...) { m <- match.call() cc <- m cc[[1]] <- as.name("

[R] geom_boxplot nocht=TRUE

2024-08-15 Thread SIBYLLE STÖCKLI via R-help
Dear community I tried to run my ggplot() +geom_boxplot() code using nocht=TRUE, but probably my term noch=TRUE is at the wrong position? Error: Error in `geom_boxplot()`: ! Problem while converting geom to grob. ℹ Error occurred in the 1st layer. Caused by error in `ans[ypos] <- rep(y

[R] allequal diff

2024-08-15 Thread SIBYLLE STÖCKLI via R-help
Dear community Similar to the example of the rdocumentation, my idea is to use all.equal and to print the difference. https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/all.equal > d45 <- pi*(1/4 + 1:10) > stopifnot( + all.equal(tan(d45), rep(1, 10))) # TRUE, b

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

2024-08-15 Thread Izmirlian, Grant (NIH/NCI) [E] via R-help
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 Sent: Thursday, August 15, 2024 2:59 PM To: Izmirlian, Grant (NIH/NCI) [E] ; r-help@r-project.org Subject

Re: [R] allequal diff

2024-08-15 Thread Ben Bolker
Digging into the code for raster::compareRaster(): library(raster) r <- raster(ncol=3, nrow=3) values(r) <- 1:ncell(r) r2 <- r values(r2) <- c(1:8,10) all.equal(getValues(r), getValues(r2), tolerance = 0) [1] "Mean relative difference: 0.111" compareRaster has fancier machinery intern

Re: [R] allequal diff

2024-08-15 Thread SIBYLLE STÖCKLI via R-help
Dear Ben Many thanks. I see that a second challenge are NA values. Is it possible to consider na.rm=TRUE? > r2_resampled <- resample(r2, r1) > compareRaster(r1, r2_resampled) [1] TRUE > > all.equal(getValues(r1), getValues(r2_resampled), tolerance = 0) [1] "'is.NA' value mismatch: 9