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
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
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
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
4 matches
Mail list logo