Error in QQ-plots

Hi guys,
I've been trying to graph using qqnorm() and qqline() as shown in the code below

p <- 0.25
N <- 100
B <- 10000
samples <- function(p, N){x <- sample(c(1, 0), N, replace = TRUE, prob = c(p, 1-p))
errors <- replicate(B, p - samples(p, N))
qqnorm(errors) + qqline(errors)

My goal is to be able to graph errors along with a line that shows proximity to a normal distribution but this error pops out:

"Error in qqnorm(errors) + qqline(errors) :
non-numeric argument to binary operator"

As I'm new to R, I not so sure of what I'm doing wrong. Can someone provide some help?
Thank you

This is a somewhat obscure situation. From the help(qqnorm) page:

y <- rt(200, df = 5)
qqnorm(y); qqline(y, col = 2)

Created on 2020-04-03 by the reprex package (v0.3.0)

Thank you,
Instead of "qqnorm(errors) + qqline(errors)" is "qqnorm(errors) ; qqline(errors)"

1 Like

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