Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

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

like image 567
zaq0718 Avatar asked Apr 24 '14 15:04

zaq0718


1 Answers

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))
like image 172
sgibb Avatar answered Sep 23 '22 07:09

sgibb