[R] Merging daily and weekly data

From: ystein Myrland <Oystein.Myrland_at_nfh.uit.no>
Date: Mon, 14 Apr 2008 12:09:12 +0200


Dear R-help group,

I have a dataset with daily closing prices from a stock exchange (consecutive 5 trading days) from a firm trading a specific commodity. The date variable looks like:

quote_date
20080411

With the format; yyyymmdd.

Moreover, I have another data set with a (average) weekly price of the underlying commodity. The date variables in this dataset are only year and a week number.

I would like to calculate a common date number or ID based on week number that enables me to merge these two datasets, so that it looks like this:

quote_date	year	week	week.price
20080407	2008	15	27.45 
20080408	2008	15	27.45
20080409	2008	15	27.45
20080410	2008	15	27.45
20080411	2008	15	27.45

The weekly price is constant for the 5 trading days in the daily file. Any good suggestions on how to do this?

All the best,
Oystein



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 Mon 14 Apr 2008 - 10:18:37 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 Mon 14 Apr 2008 - 14:30:28 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.

list of date sections of archive