We have to load the pertinent libraries to make the code operate properly.
We shall “install.packages(”plotly“)”!
library(plotly)
## Warning: package 'plotly' was built under R version 3.6.3
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
date()
## [1] "Mon Oct 12 14:53:16 2020"
If you Are looking for a nice vacation home in the state of Texas, then we can assist with the task. Play with the application below. Click on certain areas of the map and have enjoy!
Vacation1 <- plot_ly(highlight_key(txhousing, ~city, "select a city"))
D_1 <- ggplot(Vacation1, aes(date, median, group= city)) + geom_line()
Vac2 <- ggplotly(D_1, tooltip = "city") %>%
layout(title = "Click on an area for your vaction home location in Texas") %>%
highlight(dynamic = TRUE, selectize = TRUE)
## Warning: `group_by_()` is deprecated as of dplyr 0.7.0.
## Please use `group_by()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
## Adding more colors to the selection color palette.
Vac2
## Setting the `off` event (i.e., 'plotly_doubleclick') to match the `on` event (i.e., 'plotly_click'). You can change this default via the `highlight()` function.