Cet article décrit comment créer un graphique type highstock dans R en utilisant le package R highcharter.
Sommaire:
Chargement des packages R réquis
# Charger les packages R requis
library(dplyr)
library(highcharter)
# Définir les options de highcharter
options(highcharter.theme = hc_theme_smpl(tooltip = list(valueDecimals = 2)))
Préparation des données
Télécharger les taux de change en utilisant le package R quantmod. La fonction getFX() est utilisée. Il renvoie un objet de classe xts qui peut être directement représenté en utilisant le package R highcharter.
library(quantmod)
x <- getFX("USD/JPY", auto.assign = FALSE)
df <- as.data.frame(x)
head(df)
## USD.JPY
## 2019-11-05 109
## 2019-11-06 109
## 2019-11-07 109
## 2019-11-08 109
## 2019-11-09 109
## 2019-11-10 109
Visualiser les données xts de quantmod
hc <- hchart(x)
hc
Visualiser des données de symboles monétaires quantmod provenant de différentes sources
# Les objets `xts ohlc`
library(quantmod)
y <- getSymbols("SPY", auto.assign = FALSE)
hc <- hchart(y)
hc
Créer un graphique de type highstock à partir d’un jeu de données
hc <- highchart(type = "stock") %>%
hc_add_series(df$USD.JPY, type = "line")
hc
Version:

Is it possible to print in the navigator (below the graph) the date instead of numbers (I think it just prints the index of the data frame).
If so, can you tell e how to proceed?
Thanks