library(plotly)
# Load economics dataset
data(economics)
# Plot 3: 3D Scatter Plot of GDP, Population, and Unemployment
plot_ly(economics, x = ~pop, y = ~unemploy, z = ~pce, type = 'scatter3d',mode = 'markers', marker = list(color = ~pce,
colorscale = 'Viridis'), text = ~paste('Population: ', pop, '<br>Unemployment: ', unemploy, '<br>PCE: ', pce)) %>%
layout(title = '3D Scatter Plot of GDP, Population, and Unemployment',
scene = list(xaxis = list(title = 'Population'),
yaxis = list(title = 'Unemployment'),
zaxis = list(title = 'Personal Consumption Expenditures')))