output: flexdashboard::flex_dashboard: orientation: columns storyboard: true vertical_layout: fill social: menu source_code: embed —
library(readxl)
expense<- read_excel("C:/Users/supre/Desktop/Daily Expense.xlsx")
sleep <- read_excel("C:/Users/supre/Desktop/sleep.xlsx")
Questions
X <- ggplot(expense, aes(x = categories, y = categoryamount)) +
geom_bar(stat="identity") +
ggtitle("Categories (expenditure)") +
scale_y_reverse() +
theme_gdocs()
ggplotly(X)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
## Warning: Removed 14 rows containing missing values (position_stack).
Where did i spend most my money?
Y <- ggplot(expense, aes(x = Date, y = amount, color=categories)) +
geom_bar(stat="identity") +
ggtitle("Daily (expenditure)") +
scale_y_reverse() +
theme_gdocs()
ggplotly(Y)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
When did i spend most my money?
expense$wday <- weekdays(as.Date(expense$Date,'%m/%d/%Y'))
## Warning in as.POSIXlt.POSIXct(x, tz = tz): unknown timezone '%m/%d/%Y'
Z <- ggplot(expense, aes(x = factor(expense$wday, levels= c("Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")), y = amount, color=categories)) +
stat_summary(fun.y="mean",aes(shape="mean"), geom="point", color="red") +
scale_shape_manual("", values=c("mean"="x")) +
geom_bar(stat="identity") +
ggtitle("Day of the week (expenditure)") +
scale_y_reverse() +
theme_gdocs()
ggplotly(Z)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
## Warning in if (nchar(axisTitleText) > 0) {: the condition has length > 1
## and only the first element will be used
Was there any different expenditure pattern on each day of the week?
XX <- ggplot(sleep, aes(x = date, y = steps)) +
geom_point(color="yellow") +
ggtitle("Daily (steps)") +
theme_gdocs()
ggplotly(XX)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
Did i walk more than 5 miles per day?
sleep$wday <- weekdays(as.Date(sleep$date,'%m/%d/%Y'))
## Warning in as.POSIXlt.POSIXct(x, tz = tz): unknown timezone '%m/%d/%Y'
YY <- ggplot(sleep, aes(x = factor(sleep$wday, levels= c("Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")), y = steps)) +
geom_boxplot(color="grey50",fill="lightgreen")+
stat_summary(fun.y="mean", aes(shape="mean"), geom="point", color="blue") +
scale_shape_manual("", values=c("mean"="x")) +
xlab('day of the week') +
ggtitle("Day of the week (steps)") +
coord_flip() +
theme_gdocs()
ggplotly(YY)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
Which day of the week did i walk less?
durationhours<-sleep$hours
ZZ <- ggplot(sleep, aes(x = factor(sleep$wday, levels= c("Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")), y = durationhours)) +
stat_summary(fun.y="mean", aes(shape="mean"), geom="point", color="blue") +
scale_shape_manual("", values=c("mean"="x")) +
xlab('day of the week') +
ggtitle("Sleep (activity)") +
theme_gdocs()
ggplotly(ZZ)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
Did i sleep more than 6 hours per day?
p <-plot_ly(x = sleep$date, y = sleep$durationhours, type="scatter", mode="markers+lines", name="sleeping") %>%
add_trace(x = sleep$date, y=sleep$step, type="scatter", mode="markers+lines", name="step", yaxis="y2") %>%
layout(
xaxis = list(title="date"),
yaxis = list(title="hours"),
yaxis2 = list(overlaying = "y", side = "right",title="steps"),
title = "How long sleeping V.S. How many steps - Interactive Graph"
)
## Warning: Unknown or uninitialised column: 'durationhours'.
## Warning: Unknown or uninitialised column: 'step'.
ggplotly(p)
Is there any relationship betwwen sleeping duration and steps?