I am trying to understand why R is working in a particular way. I have a data set with two variables; mark date (markd) and recap date (recapd). I would like to know the number of days between capture dates. But if I subtract recap date from mark date I often get the wrong results. Example: Dataset - markd recapd 8/28/1991 12/24/1994 Timeoutd<-recapd-markd Timeoutd = 1945 But the number of days between should be around 1214. Why is this happening and how do you fix it. Thank you for all the help. RKinzer [[alternative HTML version deleted]]
Hello, Ryan Kinzer wrote:> I am trying to understand why R is working in a particular way. I have a > data set with two variables; mark date (markd) and recap date (recapd). I > would like to know the number of days between capture dates. But if I > subtract recap date from mark date I often get the wrong results.Well, what are the classes of recapd and markd in your case? Erik
Ryan Kinzer wrote:> Erik > > Thanks for helping. Both of them are factors. >That's the problem, they need to be of class Date. See the R NEWS article about Date classes in Volume 4/1. http://cran.r-project.org/doc/Rnews/ I don't see how they could be factors though, since you shouldn't be able to subtract two factors from each other without a warning at least? e.g., when I make up factors f1 and f2 >f1 - f2 <snip> Warning message: In Ops.factor(f1, f2) : - not meaningful for factors We would have to have a small, reproducible example to know for sure what's going on... Best Regards, Erik