Visually representing SD's

I am working on the Google Data Analytics Certificate and it is the Bella beat case study. I am using the Standard Deviation of the TimeSpentAsleep to look at sleep consistency. The distinct number of users is 24 and they each have multiple entries for different days. I can't seem to find a way to visually/graphically represent them in a way that is easy to comprehend and that is simple for a stakeholder to understand. I could really use some help as this is my first project in the Data Analysis Space. I really appreciate anyone's help! Thanks!

Would something like this work?

library(dplyr)
library(ggplot2)

#invent data
set.seed(123)
DF <- data.frame(Person = rep(LETTERS[1:10], 20),
                 Value = runif(200))
#Calculate mean and sd
DF_stats <- DF |> group_by(Person) |> summarize(Avg = mean(Value), Stdev = sd(Value))

#plot with error bars
ggplot(DF_stats, aes(x = Person, y = Avg)) + 
  geom_point() +
  geom_errorbar(aes(ymin = Avg - Stdev, ymax = Avg + Stdev), width = 0.25)

Created on 2024-01-18 with reprex v2.0.2

Thank you FJCC! This is what I ended up doing!

id_mapping <- data.frame(
Id = unique(original_df$Id),
Short_Id = 1:length(unique(original_df$Id))
)

original_df_mapped <- original_df %>%
left_join(id_mapping, by = "Id")

original_df_stats <- original_df_mapped %>%
group_by(Short_Id) %>%
summarize(AvgSleep = mean(TotalMinutesAsleep, na.rm = TRUE),
StdevSleep = sd(TotalMinutesAsleep, na.rm = TRUE))

original_df_stats <- original_df_stats %>%
mutate(Z_Score = (AvgSleep - mean(AvgSleep)) / sd(AvgSleep))

ggplot(original_df_stats, aes(x = Short_Id, y = AvgSleep)) +
geom_point(size = 3, color = "blue") +
geom_errorbar(aes(ymin = AvgSleep - StdevSleep, ymax = AvgSleep + StdevSleep), width = 0.25, color = "red") +
labs(title = "Mean and Standard Deviation of Total Minutes Asleep",
x = "Mapped User ID",
y = "Mean Total Minutes Asleep") +
theme_minimal()

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.