[R] 3D plot of following data
ligges at statistik.tu-dortmund.de
Tue Feb 2 16:42:29 CET 2010
On 02.02.2010 16:01, walter.djuric at chello.at wrote:
> Here they are for now for you.
> And I will put them somewhere in a few minutes and poost the link.
No need to do so. If you really want to use 3D plots (which I doubt you
really want since you could do better in 2D using dotcharts or so):
#READ IN Contracts
NG.contracts <- read.csv('NG_contracts.csv', header=FALSE, sep=";",
NG.contracts$V1 <- as.Date(NG.contracts$V1,format='%d.%m.%Y')
#READ IN Values
NG.values <- read.csv('NG_values.csv', header=FALSE, sep=";", na.string="?")
NG.values$V1 <- as.Date(NG.values$V1, format='%d.%m.%Y')
## new stuff by UL:
NG.valuesl <- reshape(NG.values, direction="long", varying=list(2:32),
NG.contractsl <- reshape(NG.contracts, direction="long",
NG <- NG.valuesl[,c("V1","V2")]
colnames(NG) <- c("Date", "value")
rownames(NG) <- NULL
NG$contract <- NG.contractsl[,"V2"]
## two ways, one for nice viewing, one for easier printout:
plot3d(NG$Date, NG$contract, NG$value)
scatterplot3d(NG$Date, NG$contract, NG$value, pch=20)
Now you need to prettify exes etc.
> ---- Uwe Ligges<ligges at statistik.tu-dortmund.de> schrieb:
>> Since your files did not come through the mail list, I'd suggest to put
>> them on some webside and provide a link.
>> Uwe Ligges
>> On 02.02.2010 13:01, walter.djuric at chello.at wrote:
>>> Hello R-experts,
>>> I am having difficulties with 3D plotting (i.e. the evolution of various forward curves through time).
>>> I have two comma seperated files both ordered by date (in the first column) one containing contracts (meaning forward delivery months from YEAR_& Letter "F" ... January through letter "Z" ... December) and the other holding the closing price of the respective contract on the day also defined in the first column (see attachments).
>>> What I would like to do is plot a three dimensional figure with trade day (date) on the X-axis, contract on the Y-axis and the price of the forward contract being the z-value.
>>> I am quite a newbie and did not manage to merge these two files in a logic way, so that R could do a 3D plot.
>>> Any help would be appreciated.
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help