I'm a total newbie to R. I'm trying to create a stacked bar chart based on this code:
activity <- c("mean_fairly_active", "mean_fairly_active", "mean_fairly_active",
"mean_fairly_active", "mean_fairly_active", "mean_fairly_active",
"mean_fairly_active", "mean_lightly_active", "mean_lightly_active",
"mean_lightly_active", "mean_lightly_active", "mean_lightly_active",
"mean_lightly_active", "mean_lightly_active", "mean_very_active",
"mean_very_active", "mean_very_active", "mean_very_active",
"mean_very_active", "mean_very_active", "mean_very_active",
"mean_sedentary", "mean_sedentary", "mean_sedentary",
"mean_sedentary", "mean_sedentary", "mean_sedentary",
"mean_sedentary")
minutes <- c("14.3", "13.1", "12.0", "12.1", "15.2", "14.5", "14.0", "197", "190",
"185", "204", "207", "174", "192", "23.0", "20.8", "19.4", "20.1",
"21.9", "20.0", "23.1", "1007", "989", "962", "1000", "964", "990",
"1028")
weekday <- c("Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun", "Mon",
"Tues", "Wed", "Thurs", "Fri", "Sat", "Sun", "Mon", "Tues", "Wed",
"Thurs", "Fri", "Sat", "Sun", "Mon", "Tues", "Wed", "Thurs", "Fri",
"Sat")
merged_means <- data.frame (activity, minutes, weekday)
print(merged_means)
The ggplot I'm running:
ggplot(merged_means, aes(x=weekday, y=minutes, fill=activity)) +
geom_bar(stat = "identity")
The resulting graph shows all the numbers of the y-axis squished on the bottom half of the graph, the days in the wrong chronological order (Fri, Mon, Sat, Sun, etc), and the fill colors in the wrong amounts. Any help is appreciated!