Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

library(quantmod) d1lt;-getSymbols(quot;AMZNquot;,from=quot;2012-01-05quot;,to=quot;2015-01-01quot;,auto.

this is an r code with a lot of errors please look into it and handle them errors.

library(quantmod)

d1<-getSymbols("AMZN",from="2012-01-05",to="2015-01-01",auto.assign = TRUE)

d2<-getSymbols("IBM",from="2012-01-05",to="2015-01-01",auto.assign = TRUE)

d3<-getSymbols("GE",from="2012-01-05",to="2015-01-01",auto.assign = TRUE)

write.zoo(AMZN,file="AMZN Yahoo.csv",sep=",")

write.zoo(AMZN,file="IBM Yahoo.csv",sep=",")

write.zoo(AMZN,file="GE Yahoo.csv",sep=",")

data.AMZN<-read.csv("AMZN Yahoo.csv",header=TRUE)

date<-data.AMZN$Index

data.AMZN<-cbind(date, data.AMZN[,-1])

data.AMZN<-data.AMZN[order(data.AMZN$date),]

data.AMZN<-xts(data.AMZN[,2:7],order.by=data.AMZN[,1])

names(data.AMZN)<-paste(c("AMZN.Open","AMZN.High","AMZN.Low","AMZN.Close","AMZN.Volume","AMZN.Adjusted"))

data.AMZN[c(1:3,nrow(data.AMZN)),]

data.IBM<-read.csv("IBM Yahoo.csv",header=TRUE)

date<-data.IBM$Index

data.IBM<-cbind(date, data.IBM[,-1])

data.IBM<-data.IBM[order(data.IBM$date),]

data.IBM<-xts(data.IBM[,2:7],order.by=data.IBM[,1])

names(data.IBM)<-paste(c("IBM.Open","IBM.High","IBM.Low","IBM.Close","IBM.Volume","IBM.Adjusted"))

data.IBM[c(1:3,nrow(data.IBM)),]

data.GE<-read.csv("GE Yahoo.csv",header=TRUE)

date<-data.GE$Index

data.GE<-cbind(date, data.GE[,-1])

data.GE<-data.GE[order(data.GE$date),]

data.GE<-xts(data.GE[,2:7],order.by=data.GE[,1])

names(data.GE)<-paste(c("GE.Open","GE.High","GE.Low","GE.Close","GE.Volume","GE.Adjusted"))

data.GE[c(1:3,nrow(data.GE)),]

Close.Prices<-data.AMZN$AMZN.Close

Close.Prices<-cbind(Close.Prices,data.GE$GE.Close,data.YHOO$YHOO.Close,data.IBM$IBM.Close)

Close.Prices[c(1:3,nrow(Close.Prices)),]

multi.df<-cbind(index(Close.Prices),data.frame(Close.Prices))

names(multi.df)<-paste(c("date","AMZN","GE","YHOO","IBM"))

rownames(multi.df)<-seq(1,nrow(multi.df),1)

multi.df[c(1:3,nrow(multi.df)),]

multi.df$AMZN.idx<-multi.df$AMZN/multi.df$AMZN

multi.df$GE.idx<-multi.df$GE/multi.df$GE

multi.df$YHOO.idx<-multi.df$YHOO/multi.df$YHOO

multi.df$IBM.idx<-multi.df$IBM/multi.df$IBM

options(digits=5)

multi.df[c(1:3,nrow(multi.df)),]

plot(x=multi.df$date,y=multi.df$GE.idx,type="l",xlab="Date",ylab="Value of Investment ($)",col="black",lty=1,lwd=2,main="Value of $1 Investment in AMZN, IBM, YHOO, and the S&P 500 Index December 31, 2010 - December 31, 2013")

lines(x=multi.df$date,y=multi.df$AMZN.idx,col="black",lty=2,lwd=1)

lines(x=multi.df$date,y=multi.df$IBM.idx,col="gray",lty=2,lwd=1)

lines(x=multi.df$date,y=multi.df$YHOO.idx,col="gray",lty=1,lwd=1)

abline(h=1,lty=1,col="black")

legend("topleft",c("AMZN","IBM","YHOO","GE"),col=c("black","gray","gray","black"),lty=c(2,2,1,1),lwd=c(1,1,1,2))

yrange<-range(multi.df[6:9,])

yrange

plot(x=multi.df$date,y=multi.df$GE.idx,type="l",xlab="Date",ylim=yrange,ylab="Value of Investment ($)",col="black",lty=1,lwd=2,main="Value of $1 Investment in AMZN, IBM, YHOO, and the S&P 500 Index December 31, 2010 - December 31, 2013")

lines(x=multi.df$date,y=multi.df$AMZN.idx,col="black",lty=2,lwd=1)

lines(x=multi.df$date,y=multi.df$IBM.idx,col="gray",lty=2,lwd=1)

lines(x=multi.df$date,y=multi.df$YHOO.idx,col="gray",lty=1,lwd=1)

abline(h=1,lty=1,col="black")

legend("topleft",c("AMZN","IBM","YHOO","S&P 500 Index"),col=c("black","gray","gray","black"),lty=c(2,2,1,1),lwd=c(1,1,1,2))

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question