Re: [R] Getting a Error: unexpected symbol in:

2014-12-12 Thread Jeff Newmiller
The body of a function needs to be wrapped in one pair of braces. diffdate<-function(x,y){ z<-unclass(as.Date(x)) z1<-unclass(as.Date(y)) return(z1-z) } It is common in R to make sure that date values are of the appropriate type before you call the function instead of do

Re: [R] Getting a Error: unexpected symbol in:

2014-12-12 Thread David Winsemius
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 func

Re: [R] Getting a Error: unexpected symbol in:

2014-12-12 Thread Bert Gunter
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

[R] Getting a Error: unexpected symbol in:

2014-12-12 Thread Sajjad Jafri
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<-functi