[R] Number of Days

Gabor Grothendieck ggrothendieck at myway.com
Thu Nov 6 15:44:10 CET 2003



ndays <- strptime(ex,format="%d%b%Y") - strptime(x,format="%d%b%Y")

If you need it in a calculation then as.numeric(ndays) might be
useful.

---
 
Date: Wed, 5 Nov 2003 23:33:33 -0600 
From: umeno <umeno at students.uiuc.edu>
To: R-Help  
Subject: [R] Number of Days 

 
 
Hi everyone,

I have been trying to compute numbers of days between two dates as follows:

> x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960")
> z <- format(x, "%d%b%Y")
> ex <- c("1jan1961", "15jan1960", "21mar1975", "10jul1981")
> ez <- format(ex, "%d%b%Y")
> ez-z
Error in ez - z : non-numeric argument to binary operator

As you may see, I am getting an error. Can anyone tell me how I can convert z 
and ez to numeric vectors, so that I can compute days between the 
corresponding dates in these vectors?

thank you
soyoko

______________________________________
Ms. Soyoko Umeno
Graduate Research Assitant for the Illinois-Missouri Biotechnology Alliance (IMBA) at http://www.imba.missouri.edu/
Ph.D. Student at the Department of Agricultural and Consumer Economics
at the University of Illinois at Urbana-Champaign
Office Phone: 217-333-3417 or 217-333-0364
Fax: 217-244-4817
Mailing Address: 1301 W. Gregory Dr. MC710, Urbana, IL 61801


_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com




More information about the R-help mailing list