[R] calculating age from year of birth and date?

2010-04-21 Thread Vlatka Matković Puljić
Hi, I have v1 (date of test) and v2 (year of birth). v1 v2 15.5.2008 88 18.6.200954 I want R to use only year in v1; and v2 see as 1988 and calculate age in v3. any ideas how to do that? -- ** Vlatka Matković Puljić 095/8618 171

[R] calculating age from year of birth and date?

2010-04-21 Thread Vlatka Matkovic Puljic
Hi, I have v1 (date of test) and v2 (year of birth). v1 v2 15.5.2008 88 18.6.200954 I want R to use only year in v1; and v2 see as 1988 and calculate age in v3. any ideas how to do that? -- ** Vlatka Matković Puljić 095/8618 171

Re: [R] calculating age from year of birth and date?

2010-04-21 Thread Dimitri Liakhovitski
In what format are you dates? Are they always like this: two digits for day, then one or two digits for month, and four digits for the year? Also - are any of your people born after 1999? Dimitri 2010/4/21 Vlatka Matković Puljić vlatk...@gmail.com: Hi, I have v1 (date of test) and v2 (year

Re: [R] calculating age from year of birth and date?

2010-04-21 Thread Dimitri Liakhovitski
And what is the format for year of birth in Excel? Can't you use concatenate to concatenate a new column (that contains only 19) and the column that contains a 2-digit year of birth? And then change all those who are born (in the new column) before 1910 to XX+100 - which will give you 2009 (or

Re: [R] calculating age from year of birth and date?

2010-04-21 Thread Vlatka Matkovic Puljic
Hm, well.. I can do it in xls but I wanted to see if there is some (simple) way to do this in R. 2010/4/21 Dimitri Liakhovitski ld7...@gmail.com And what is the format for year of birth in Excel? Can't you use concatenate to concatenate a new column (that contains only 19) and the column that

Re: [R] calculating age from year of birth and date?

2010-04-21 Thread Dimitri Liakhovitski
Give what you've given us, you can try: x-data.frame(date=c(39804,9527,39917),birth=c(1988,1911,1969)) # your years have to be in 4-digit format # formatting date as Date. What you have is, I think, number of days since 1900 - can anyone correct me? x$date-as.Date(x$date,origin=1900-01-01)