Row
list(
icon = "gender-male",
color = p_males_color,
value = label_percent(accuracy = 0.1)(p_males)
)
## $icon
## [1] "gender-male"
##
## $color
## [1] "primary"
##
## $value
## [1] "49.1%"
list(
icon = "globe-americas",
color = p_ethnicity_color,
value = label_percent(accuracy = 0.1)(p_ethnicity)
)
## $icon
## [1] "globe-americas"
##
## $color
## [1] "success"
##
## $value
## [1] "88.9%"
list(
icon = "graph-up-arrow",
color = p_age_color,
value = (p_age)
)
## $icon
## [1] "graph-up-arrow"
##
## $color
## [1] "info"
##
## $value
## [1] 65
Row
# Create a histogram for Age distribution
age_hist <- plot_ly(data, x = ~Age, type = 'histogram',
marker = list(color = 'rgba(0, 123, 255, 0.7)'),
name = "Age Distribution") %>%
layout(xaxis = list(title = "Age"),
yaxis = list(title = "Count"),
bargap = 0.2)
# Display the plot
age_hist
## Warning: Ignoring 24 observations
age_plot <- data %>%
plot_ly(x = ~Age, color = ~Gender, type = "histogram") %>%
layout(
xaxis = list(title = "Age", tickangle = 0), # Rotate x-axis labels to be vertical
yaxis = list(title = "Count")
)
age_plot
## Warning: Ignoring 24 observations
gender_donut <-
plot_ly(
data = subset(data, !is.na(Gender)),
labels = ~Gender,
type = "pie",
hole = 0.4, # Set the size of the hole for a donut effect
marker = list(colors = c( "yellow", "violet")) # Customize colors as needed
) %>%
layout(
showlegend = TRUE # Set to FALSE if you don't want to show the legend
)
# Print the plot
gender_donut
# Create a pie chart for Gender distribution without NA values
gender_pie <- plot_ly(data = subset(data, !is.na(Gender)), labels = ~Gender, type = 'pie',
marker = list(colors = c("lightblue","hotpink","purple"),
line = list(color = 'rgba(255, 255, 255, 1)', width = 5))) %>%
layout( showlegend = TRUE)
# Display the plot
gender_pie
s<- c(Straight= 646,Bisexual=43, Gay = 5, Lesbian=10, Queer=22, Questioning= 6, Other =65)
waffle(s, size = 0, rows = 18)

# Count occurrences of each Ethnicity
ethnicity_counts <- table(data$Ethnicity)
# Create plotly donut chart
plot_ly(labels = names(ethnicity_counts), values = ethnicity_counts, type = 'pie',
textinfo = 'percent', hole = 0.6) %>%
layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
age_sexuality_plot <- subset(data, !is.na(Sexuality)) %>%
plot_ly(x = ~Age, color = ~Sexuality, type = "histogram",xbins = list(size = 15)) %>%
layout(
xaxis = list(title = "Age", tickangle = 0),
yaxis = list(title = "Count"))
age_sexuality_plot
age_ethnicity_plot <- subset(data, !is.na(Ethnicity)) %>%
plot_ly(x = ~Age, color = ~Ethnicity, type = "histogram",xbins = list(size = 15)) %>%
layout(
xaxis = list(title = "Age", tickangle = 0),
yaxis = list(title = "Count"))
age_ethnicity_plot
age_disability_plot <- subset(data, !is.na(Disability)) %>%
plot_ly(x = ~Age, color = ~Disability, type = "histogram",xbins = list(size = 15)) %>%
layout(
xaxis = list(title = "Age", tickangle = 0),
yaxis = list(title = "Count"))
age_disability_plot