Expect to come across this, one of the most important data visualization in R interview questions for experienced professionals in data science, in your next interviews. We can use the RColorBrewer library in R to choose from different colours for different columns in a dataset. We can use “dygraphs” library in R in addition to that. It creates an interactive chart with values can be shown to the point where we hover around our cursor after plotting the graph. The “dygraphs” library in R is having interactive feature out of the box, with default mouse-over labels and we can also perform zooming and panning. For this, we are considering the “lungDeaths” dataset in R which has deaths from lung disease in the UK captured for a period of few years from 1974 to 1979. library(dygraphs)
lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
dyOptions(colors = RColorBrewer::brewer.pal(3, "Set2")) Sample chart output: