0

The data below contains 2 columns I want to plot against each other: . Currently, I can create barplot. But the x-axis is sorted alphabetically. How do I want arrange the x-labels in the order of week: Monday-Sunday?

# Summarize data by date
data$dow = format(data$date, format = "%a")

steps_by_dow <- data %>% 
                group_by(dow) %>% 
                summarize(sum_steps = mean(steps))

# plot histogram for total steps per day
barplot(sum_steps ~ dow, steps_by_dow, xlab = "Daily steps", ylab = "Count (step)", 
     main = "Histogram of the total steps taken per day")

enter image description here

techtana
  • 315
  • 2
  • 9

0 Answers0