Hello HanOostdijk,
I tried it but it doesn't work. I get a linear line and the date are no more in the x abscisse(because I want the prices in the x abscisse):
I did the following code:
#Put the data in a matrix p
p <-read.csv("JSE_Price_index_and_Total_Returns1.csv", header = TRUE , sep = ",")
names(p)
names(p)<-c("Date","Price Index","Total Return Index")
#Adjust date format
install.packages("lubridate") # when not yet installed: uncomment this line
library (lubridate)
p$Date2 = lubridate::parse_date_time(p$Date,"%m/%d/%Y")
#Representer Price Index - plot:
plot(p$Date2, p$Price_Index, type = "l", col="black", lwd = 1)
#Another way to plot:
plot(as.Date(p$Date2),p$Price_Index, type = "l", col="black", lwd = 1)
Here are the class of Date and of Date2:
class(p$Date2)
[1] "POSIXct" "POSIXt"
class(p$Date)
[1] "character"
Here is the output in the table :
head(p)
Date Price Index Total Return Index Date2
1 06/05/2006 100.0 100.00 2006-06-05
2 06/06/2006 90.7 90.68 2006-06-06
3 06/07/2006 86.2 86.19 2006-06-07
4 06/08/2006 82.5 82.47 2006-06-08
5 06/09/2006 94.8 94.85 2006-06-09
6 06/12/2006 88.2 88.25 2006-06-12
And here are the linear graph : I get the same with other way of plotting the data:
Linear line like that (https://www.google.com/search?q=linear+line+&tbm=isch&ved=2ahUKEwj9kczSseXxAhV_EGMBHZ_dCgMQ2-cCegQIABAA&oq=linear+line+&gs_lcp=CgNpbWcQAzIECCMQJzICCAAyAggAMgIIADICCAAyAggAMgIIADICCAAyAggAMgIIADoHCCMQ6gIQJzoECAAQQ1ChAVjCHWC3H2gBcAB4BIABzgKIAbARkgEHOC40LjIuMpgBAKABAaoBC2d3cy13aXotaW1nsAEKwAEB&sclient=img&ei=xlPwYP2WLP-gjLsPn7urGA&bih=769&biw=1368&rlz=1C1CHBF_frFR885FR885#imgrc=JS1wlhb0VHcWOM)
NB: I can't post picture of the graph
Please, I don't know how to solve it.
Thanks in advance.
Tati