Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

quantmod 3d graphics

Tags:

r

3d

quantmod

I am trying to use the code on the quantmod website for a 3d graph. I followed the instructions and entered the year as 2010 (since 2008 link was not found). However, when I enter this command at the R prompt:

 chartSeries3d0(TR)

I get the following error:

Error in if (on == "years") { : missing value where TRUE/FALSE needed

I am relatively new to R, so can anyone help me fix it.

like image 348
itcplpl Avatar asked Mar 15 '26 07:03

itcplpl


1 Answers

The Treasury has re-designed its website since that example was created, so the code is not downloading any data (no matter what year you enter). Instead of using the getUSTreasuries function, you can just pull the data from FRED.

library(quantmod)
source("http://www.quantmod.com/examples/chartSeries3d/chartSeries3d.alpha.R")

getSymbols("DGS1MO;DGS3MO;DGS6MO;DGS1;DGS2;DGS3;DGS5;DGS7;DGS10;DGS20;DGS30",
  src="FRED")
TR <- merge(DGS1MO,DGS3MO,DGS6MO,DGS1,DGS2,DGS3,DGS5,
  DGS7,DGS10,DGS20,DGS30, all=FALSE)
colnames(TR) <- c("1mo","3mo","6mo","1yr","2yr","3yr","5yr",
  "7yr","10yr","20yr","30yr")
TR <- na.locf(TR)

chartSeries3d0(TR["2011"])
like image 167
Joshua Ulrich Avatar answered Mar 17 '26 20:03

Joshua Ulrich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!