Error: unexpected '}' in "}" in R [duplicate]

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

3

1 Answer

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)) 
2

You Might Also Like