Error Message for GGPLot

ggplot(Power80_DATA, aes(x = sample.size, y = sample.cohend))+

  • geom_point(size = 5)+
  • scale_x_continuous(limits = c(40,2000), breaks = c(0,500,1000,1500,2000))+
  • scale_y_continuous(limits = c(0,1.00), breaks = c(0,.10,.20,.30,.40,.50,.60,.70,.80,.90,1.00))+
  • annotate("rect", ymin = 0.8, ymax = 1, alpha = .3, fill = "red",
  •        xmin=40,xmax=2000)+
    
  • annotate("rect", ymin = 0.5, ymax = .8, alpha = .3, fill = "orange",
  •        xmin=40,xmax=2000)+
    
  • annotate("rect", ymin = 0.2, ymax = .5, alpha = .3, fill = "yellow",
  •        xmin=40,xmax=2000)+
    
  • annotate("rect", ymin = 0, ymax = .2, alpha = .3, fill = "lightgreen",
  •        xmin=40,xmax=2000)+
    
  • annotate("text", x = 400, y = .9, label = "Large", size=16)+
  • annotate("text", x = 400, y = .65, label = "Moderate", size=16)+
  • annotate("text", x = 400, y = .35, label = "Small", size=16)+
  • annotate("text", x = 400, y = .1, label = "Neligible", size=16)+
  • xlab("Size of Treatment Group and Control Group")+ylab("Cohen's D Detected")+
  • ggtitle("If we had a group sample size of ___ and 80% power, we could detect a ___ difference at p<.05")+
  • theme(legend.position= "bottom",
  •     legend.justification = 'center',
    
  •     legend.title=element_blank(),
    
  •     legend.key.size = unit(1.5, "cm"),
    
  •     legend.box="vertical",
    
  •     line = element_line(colour = "black", size = 1), 
    
  •     axis.line = element_line(colour = "black"), 
    
  •     panel.border= element_blank(), 
    
  •     panel.grid.major = element_line(colour = "lightgray"), 
    
  •     panel.grid.minor = element_line(colour = "lightgray"), 
    
  •     panel.background = element_blank(),
    
  •     title = element_text(family="Times New Roman", size=54),
    
  •     axis.title.x = element_text(family="Times New Roman",colour = "Black", margin = margin(t = 20, r = 0, b = 0, l = 0), size=54),
    
  •     axis.title.y = element_text(family="Times New Roman",colour = "Black", margin = margin(t = 0, r = 20, b = 0, l = 0), size=54), 
    
  •     axis.text= element_text(family="Times New Roman", size=54, color = "Black"), 
    
  •     text= element_text(family="Times New Roman", size=54), 
    
  •     plot.margin = margin(t = 2, r = 2, b = 2, l = 2, unit = "cm")) 
    

Error in findInterval(angle, c(0, 90, 180, 270, 360)) :
5 arguments passed to .Internal(findInterval) which requires 6

sessionInfo()
R version 4.5.1 (2025-06-13 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggpubr_0.6.1 remotes_2.5.0 extrafont_0.19 lubridate_1.9.4 forcats_1.0.0 stringr_1.5.2 dplyr_1.1.4
[8] purrr_1.1.0 readr_2.1.5 tidyr_1.3.1 tibble_3.3.0 ggplot2_4.0.0 tidyverse_2.0.0 doRNG_1.8.6.2
[15] rngtools_1.5.2 data.table_1.17.8 pastecs_1.4.2 doParallel_1.0.17 iterators_1.0.14 foreach_1.5.2 pwr_1.3-0

loaded via a namespace (and not attached):
[1] utf8_1.2.6 generics_0.1.4 rstatix_0.7.2 stringi_1.8.7 extrafontdb_1.0 hms_1.1.3 digest_0.6.37
[8] magrittr_2.0.4 grid_4.4.1 timechange_0.3.0 RColorBrewer_1.1-3 backports_1.5.0 Formula_1.2-5 fansi_1.0.6
[15] scales_1.4.0 codetools_0.2-20 abind_1.4-8 cli_3.6.5 crayon_1.5.3 rlang_1.1.6 withr_3.0.2
[22] tools_4.4.1 tzdb_0.5.0 ggsignif_0.6.4 boot_1.3-32 broom_1.0.10 vctrs_0.6.5 R6_2.6.1
[29] lifecycle_1.0.4 car_3.1-3 pkgconfig_2.0.3 pillar_1.9.0 gtable_0.3.6 glue_1.8.0 tidyselect_1.2.1
[36] rstudioapi_0.17.1 farver_2.1.2 carData_3.0-5 Rttf2pt1_1.3.12 compiler_4.4.1 S7_0.2.0

There isn't anything obvious that I can see, but it's a little difficult as I can't run the code. Can you generate a version of the code, with data, that we can run ourselves? Then we might be able to help.

Here is the code block that generates the code and creates the plot. I seem to be only getting this error for the plot when I run R 4.5.1.

library("pwr")
library(doParallel)
library(pastecs)
library(parallel)
library(foreach)
library(data.table)
library(doRNG) 
library(tidyverse)
library(ggplot2)
library(extrafont)
library(remotes)
library(ggpubr)
detectCores()
registerDoParallel(12)

N<-100


# Power 80 Analysis ####

set.seed(1992)
Power80_DATA = foreach (i=1:N, .packages = "pwr", .errorhandling = 'remove', .combine=rbind) %dorng%                                
  {
    
    n<-round(runif(1,0,2000))
    
    
    Power<-power.t.test(n = n, delta = NULL, sd = 1, sig.level = 0.05, power = .80,
                        type = c("two.sample"))
    
    sample.size<-Power$n
    sample.power<-Power$power
    sample.cohend<-Power$delta
    sample.sig<-Power$sig.level
    
    data.frame(sample.size,sample.power,sample.cohend,sample.sig)
    
  }


## Figure


ggplot(Power80_DATA, aes(x = sample.size, y = sample.cohend))+
  geom_point(size = 5)+
  scale_x_continuous(limits = c(40,2000), breaks = c(0,500,1000,1500,2000))+
  scale_y_continuous(limits = c(0,1.00), breaks = c(0,.10,.20,.30,.40,.50,.60,.70,.80,.90,1.00))+
  annotate("rect", ymin = 0.8, ymax = 1, alpha = .3, fill = "red", 
           xmin=40,xmax=2000)+
  annotate("rect", ymin = 0.5, ymax = .8, alpha = .3, fill = "orange", 
           xmin=40,xmax=2000)+
  annotate("rect", ymin = 0.2, ymax = .5, alpha = .3, fill = "yellow", 
           xmin=40,xmax=2000)+
  annotate("rect", ymin = 0, ymax = .2, alpha = .3, fill = "lightgreen", 
           xmin=40,xmax=2000)+
  annotate("text", x = 400, y = .9, label = "Large",  size=16)+
  annotate("text", x = 400, y = .65, label = "Moderate",  size=16)+
  annotate("text", x = 400, y = .35, label = "Small",  size=16)+
  annotate("text", x = 400, y = .1, label = "Neligible",  size=16)+
  xlab("Size of Treatment Group and Control Group")+ylab("Cohen's D Detected")+
  ggtitle("If we had a group sample size of ___ and 80% power, we could detect a ___ difference at p<.05")+
  theme(legend.position= "bottom",
        legend.justification = 'center',
        legend.title=element_blank(),
        legend.key.size = unit(1.5, "cm"),
        legend.box="vertical",
        line = element_line(colour = "black", size = 1), 
        axis.line = element_line(colour = "black"), 
        panel.border= element_blank(), 
        panel.grid.major = element_line(colour = "lightgray"), 
        panel.grid.minor = element_line(colour = "lightgray"), 
        panel.background = element_blank(),
        title = element_text(family="Times New Roman", size=54),
        axis.title.x = element_text(family="Times New Roman",colour = "Black", margin = margin(t = 20, r = 0, b = 0, l = 0), size=54),
        axis.title.y = element_text(family="Times New Roman",colour = "Black", margin = margin(t = 0, r = 20, b = 0, l = 0), size=54), 
        axis.text= element_text(family="Times New Roman", size=54, color = "Black"), 
        text= element_text(family="Times New Roman", size=54), 
        plot.margin = margin(t = 2, r = 2, b = 2, l = 2, unit = "cm")) 


type or paste code here

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.