I am praticing R codes. When I type
sim.clt <- function (m=100,n=10,p=0.25)
{ z = rbinom(m,n,p)
x = (z-n*p)/sqrt(n*p*(1-p))
hist(x,prob=T,breaks=20,main=paste("n =",n,”p =”,p))
curve(dnorm(x),add=T)
}
It gives me errors:
Error: unexpected input in:
" x = (z-n*p)/sqrt(n*p*(1-p))
hist(x,prob=T,breaks=20,main=paste("n =",n,?
> curve(dnorm(x),add=T)
> }
Error: unexpected '}' in "}"
>
How to I fix the error? Thank you
It seems you using unicode characters in your code: ”p =”,p)
.
Replace
hist(x,prob=T,breaks=20,main=paste("n =",n,”p =”,p))
by
hist(x,prob=T,breaks=20,main=paste("n =",n, "p =",p))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With