Error: unexpected '}' in "}" in R

I relate to R codes. When i type

sim.clt <- function (m=100,n=10,p=0.25) { z = rbinom(m,n,p) x = (zn*p)/sqrt(n*p*(1-p)) hist(x,prob=T,breaks=20,main=paste("n =",n,"p =",p)) curve(dnorm(x),add=T) } 

This gives me errors:

 Error: unexpected input in: " x = (zn*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 fix the error? thank you

+6
source share
1 answer

It seems you are 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)) 
+8
source

All Articles