Skip to content

Instantly share code, notes, and snippets.

@hongo35
Created September 20, 2014 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hongo35/1ad54ce8cf217b62cda8 to your computer and use it in GitHub Desktop.
Save hongo35/1ad54ce8cf217b62cda8 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(scales)
# データの読み込み
data <- read.csv("/path/to/activities.csv", header=T)
# 基本統計量
summary(data$steps)
# グラフ(日ごとの推移)
graph <- ggplot(data, aes(x=as.Date(date), y=steps, fill=weekday)) + scale_fill_gradientn(colours=c('#ff4500', '#434348', '#434348', '#434348', '#434348', '#434348', '#87cefa')) + geom_bar(stat='identity') + scale_x_date(label = date_format("%m月%d日")) + theme_bw(base_family = "Osaka") + xlab("日時") + ylab("歩数") + ggtitle("歩数の時系列推移")
plot(graph)
# グラフ(曜日別)
graph <- ggplot(data, aes(x=as.character(weekday), y=steps)) + geom_boxplot() + theme_bw(base_family = "Osaka") + scale_x_discrete(labels=c('日','月','火','水','木','金','土')) + xlab("曜日") + ylab("歩数")
plot(graph)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment