RPubs will retire in June 2027. Your existing documents will stay accessible through December 31, 2031
and Connect Cloud is the recommended home for new publishing. Read the blog post

Recently Published

NikhilBharadwaj_DA_E2
Document
Module 3 - Matt Miller
Sams map of housing costs and income in massachusetts
DONT RESHARE THIS IT IS A WORK IN PROGRESS AND MY API KEYS ARE DISPLAYED
Project 2
TALLER 14
Actividad No. 1 - Métodos estadísticas
Desarrollo de la actividad No. 1 del curso de métodos estadísticos
Life expectancy ovedr time by countryHTML
# Load necessary libraries library(ggplot2) library(plotly) library(htmlwidgets) # Create the ggplot object gg_life_expectancy <- ggplot(data, aes(x = Year, y = Life_expectancy, group = Country, color = Country)) + geom_line(alpha = 0.5) + theme_minimal() + theme(legend.position = "none") + labs(title = "Life Expectancy over Time by Country", x = "Year", y = "Life Expectancy") # Convert the ggplot object to a Plotly object p_plotly <- ggplotly(gg_life_expectancy) # Display the interactive plot in the RStudio viewer or your web browser print(p_plotly) # Save the Plotly plot as an HTML file htmlwidgets::saveWidget(p_plotly, "Life_Expectancy_Over_Time_Plotly.html")
R Code for Interactive Pairwise Scatter Plots with Plotly HTML
# Load necessary libraries library(plotly) library(dplyr) # Select variables select_vars <- c("Life_expectancy", "Adult_mortality", "Alcohol_consumption", "GDP_per_capita", "Schooling") # Create a data frame for pairwise scatter plots pairwise_data <- data %>% select(select_vars) # Create a list to store Plotly scatter plot objects plot_list <- list() # Loop through each combination of variables for pairwise scatter plots for(i in 1:length(select_vars)) { for(j in 1:length(select_vars)) { # Avoid plotting a variable against itself if(i != j) { p <- plot_ly(pairwise_data, x = ~get(select_vars[i]), y = ~get(select_vars[j]), type = 'scatter', mode = 'markers', marker = list(size = 10, opacity = 0.5), xaxis = paste0("x", i), yaxis = paste0("y", j), name = paste(select_vars[i], "vs", select_vars[j])) plot_list[[length(plot_list) + 1]] <- p } } } # Combine all plots final_plot <- subplot(plot_list, nrows = length(select_vars), ncols = length(select_vars), shareX = TRUE, shareY = TRUE) # Display the interactive plot in the RStudio viewer or your web browser print(final_plot) # Save the Plotly plot as an HTML file htmlwidgets::saveWidget(final_plot, "Pairwise_Scatterplots_Plotly.html")
BAN 350 Assignment 3