mydata <- read.csv("https://query1.finance.yahoo.com/v7/finance/download/TSLA?period1=1693440000&period2=1699228800&interval=1d&events=history&includeAdjustedClose=true") head(mydata) library(lubridate) mydata$Date=ymd(mydata$Date) ##This is a "comment". R doesn't process this line ##I ask: suppose I invest $1 on Aug 31 2023. How many shares will I have bought? What will that $1 turn into over my investment period? ##Simply: if the price of TSLA on Aug 31 2023 is $258, then to invest $1 I need to buy 1/258th of a share. This will turn into whatever 1/258th of a share is worth firstprice=mydata[1,"Adj.Close"] mydata$perfofonedollar=mydata$Adj.Close/firstprice library(ggplot2) ##Create the graph p <- ggplot(data=mydata)+ geom_path(aes(x=Date, y=perfofonedollar, group=1)) ##Save the graph ggsave(p, file="p.png")