[R] dates and time series management

Zilefac Elvis zilefacelvis at yahoo.com
Wed Jun 5 00:23:36 CEST 2013


Hi,
I have 100 files (4 attached for your reference) with different file names,
different start and end dates. Years and months occupy 1st and 2nd columns while days occupy the rest of the 33 columns in each file.

If date starts before 1961 and ends after 2005, extract all rows between 1961 to 2005 in all 100 files,
else, if date starts after 1961 and does not go up till 2005, retain the values as they are, then generate a date vector "%Y-%m" from 1961 to 2005 and fill spaces without values using 'NA'. For example, in one file I have data from 1970 to 2000. I would like to generate dates from 1961 to 2005, fill 1961-1966, and 2001-2005 with 'NA'. Do same for all 100 files.

After doing the extracting and replacing, all files will have a common date window (1961-2005).
Now, delete year and month from each file (i.e. first two columns in each file) and convert each file to as.vector (column vector. i.e take column 4 and place under column 3 etc). My expected output would then be 100 files each having a column vector.

Finally, I would like to use the original file names as the resulting column names for each file. Then combine all 100 files in a data.frame

Using 4 files, final output should be 'equal rows * 4 columns', e.g 16354 rows * 4 columns, say.

Thanks so much.
 
Atem
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dt3031093.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130604/b1496dc3/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dt3031400.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130604/b1496dc3/attachment-0001.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dt3032800.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130604/b1496dc3/attachment-0002.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dt3033880.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130604/b1496dc3/attachment-0003.txt>


More information about the R-help mailing list