[R] Extracting Year (only) information from Non-Standard Dates

From: Anupa Fabian <anupa.fabian_at_yahoo.com>
Date: Sun, 16 Dec 2007 19:34:15 +0700 (ICT)


I have some data whose date column consists of two types of date entries: (a) year-only entries (eg "1983") and
(b) full date info (eg September 12, 1962).

Here's what the non-standard date info looks like:
> mode(non.standard.dates)

[1] "numeric"
> head(non.standard.dates)

[1] July 15, 1925     February 13, 1923 July 10, 1988     February 24, 1931
[5] 1952     January 9, 1957

1638 Levels: 1732 1735 1736 1740 1745 1748 1749 1750 1752 1754 1757 1760 ... September 9, 1898

I just want to extract out the year information (viz in the example above: 1925, 1923, 1988, 1931, 1952 and 1957) and create a "year" column. Have tried using the R date libraries without success, but they seem more designed for working with dates which are standardized the same way.... I'd really appreciate suggestions from more experienced R folks. Thank you.



Never miss a thing. Make Yahoo your home page.

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 16 Dec 2007 - 15:13:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 16 Dec 2007 - 16:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.