Loading the data
This week's tidy Tuesday data set for 2023-02-07 is concerned with tech company stock prices. Let's load the data:
Show the code
library(dygraphs)
library(quantmod)
library(tidyverse)
library(highcharter)
big_tech_companies <-readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-02-07/big_tech_companies.csv',show_col_types = FALSE)The data gives us an overview of the symbols for a few tech companies:
Show the code
big_tech_companiesAlthough there was corresponding open and closing data for this week's data, we will take a slightly different approach and will integrate different packages to retrieve that information. Let's focus on Netflix Inc., NVIDIA Corporation, and Salesforce Inc.. We can get the stock information for these companies by specifying their symbol, when using the getSymbols() function from the quantmod package:
Show the code
NVIDIA <- getSymbols("NVDA", auto.assign = FALSE)
NETFLIX <- getSymbols("NFLX", auto.assign = FALSE)
SALESFORCE <- getSymbols("CRM", auto.assign = FALSE)If you are curious as to how this data may look like, you can call one of the objects:
Show the code
NETFLIX %>%
head(4)Data Visualisation
Now that we have our data, we can proceed to visualise it. We will use the highcharter package, which has some built in functionality, let's use open-high-low-close chart for the Netflix and Salesforce stocks, for the NVIDIA stocks let's use a candlestick plot:
Show the code
highchart(type = "stock") |>
hc_add_series(NVIDIA) |>
hc_add_series(NETFLIX, type = "ohlc") %>%
hc_add_series(SALESFORCE, type = "ohlc") %>%
hc_add_theme(hc_theme_monokai())The widget offers some interactive elements, play around with it to understand more about the stock prices of the companies over time!