On Jul 14, 2008, at 3:03 AM, Megh Dal wrote:
> Hi,
> following data is taken from http://www.economagic.com/em-cgi/
> data.exe/var/west-texas-crude-long. Problem with this data is when
> you copy it from this site you would get something like that :
>
> 1946 063331.27
> 1946 079991.27
> 1946 087771.52
> 1946 096661.52
>
> They should be interpret in following way :
>
> 1946 063331.27 this means : on 1946, June price was 1.27. Can
> anyone please suggest me the easiest way with R to get extracted
> the entire series?
>
>
Hi,
You can extract the year, month and price with the following:
> s = c("1946 063331.27", "1946 079991.27")
> nc = nchar(s)
> y = substr(s, 1,4)
> m = substr(s, 6,7)
> p = substr(s,nc-3,nc)
> y
[1] "1946" "1946"
> m
[1] "06" "07"
> p
[1] "1.27" "1.27"
But you will want to pay attention to what happens when the price
requires more digits.
Cheers,
Ben
P.S. Wow! A 20% increase in the cost of oil in one month! Will
wonders never cease?
Ben Tupper
PemaquidRiver at tidewater.net
I GoodSearch for Ashwood Waldorf School.
Raise money for your favorite charity or school just by searching the
Internet with GoodSearch - www.goodsearch.com - powered by Yahoo!