2024-03-02

Loading libraries

library(plotly)
library(tidyverse)
library(lubridate)

3D Surface plot from faithfuld dataset

data("faithfuld")
plot_ly(z = as.matrix(faithful), type = "surface")

Reading data download from url

# Data downloaded from below url in csv format that data was read into R
# https://www.nseindia.com/reports-indices-historical-index-data
nifty_df <- read.csv("NIFTY 50-02-12-2023-to-02-03-2024.csv")
nifty_df <- nifty_df[-63,]
nfy_df <- nifty_df[,2:4] %>%
  gather(index, price) %>%
  mutate(date = rep(nifty_df$Date, 3))

Time series plot, NIFTY 50, Q4, FY-2023

plot_ly(nfy_df, x = ~dmy(date), y = ~price, color = ~index, 
        type = "scatter", mode = "line")