Reputation: 33
I need to produce a line graph with two lines into the graph, one for the return of an asset and the other for a "Compound" factor, on the X axis you will have the days. My current code is the following:
lines(1:64,dataf[,3])
lines(1:64,data2$Change)
This of course gives me two line graphs, but I would like to have one graph with 1:64 (the days) on the X axis and "dataf[,3]" plus "data2$Change" as lines, can someone help me? thanks!!
Upvotes: 1
Views: 126
Reputation: 25375
You should first use plot() to create a new plot. lines()
will add your line to the existing plot. Example:
plot(x = seq(1:10), y = seq(1:10),type = "l",col = "red")
lines(x = seq(1,10), y = seq(1,20,by=2), col = "green")
Upvotes: 1