[R] Getting a Error: unexpected symbol in:

David Winsemius dwinsemius at comcast.net
Sat Dec 13 04:44:16 CET 2014

On Dec 12, 2014, at 1:43 PM, Sajjad Jafri 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:

What do you mean "when you run the function"? I do not see any calls to the function.

I do see an error message but the functions was defined, nonetheless. All you need to do is type `diffdate` to see it. You will probably be surprised.

> 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]]

Read the Posting Guide regarding teh desired format of posts.

> ______________________________________________
> 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.

David Winsemius
Alameda, CA, USA

More information about the R-help mailing list