[R] Getting a Error: unexpected symbol in:

Bert Gunter gunter.berton at gene.com
Sat Dec 13 04:11:10 CET 2014

As what is going on is completely obvious, I think you need to consult
a local programmer to explain it to you -- probably a 15 year old kid
will do. Seriously. Doesn't have to know R (other than that a
multiline's function's code/body must be enclosed in "{ }." Perhaps
reading an R tutorial (maybe "An Intro to R", which ships with R --
have you read it? If not, why not??)  might also do.


Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll

On Fri, Dec 12, 2014 at 1:43 PM, Sajjad Jafri <sjafri83 at gmail.com> wrote:
> I am trying to create a simple function that finds the number of days
> between two dates. However, when I run the  function, R gives me an error
> message saying:
> unexpected '}' in "        }"
> Here is my function:
> #create a function that finds the number of days between two dates
> diffdate<-function(x,y){
>         z<-unclass(as.Date(x))
>         z1<-unclass(as.Date(y))
>         }
>         {
>                 return z1-z
>         }
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list