Introduction

In this final project, Professor Alan Hitch introduced me to the Quantified Self movement. I am going to visualize some aspects of my life based on the data I collected.

I have three datasets with calories burn data starting on 11/13/22, travel data for the last 6 months (2+ days-long trips), and music play data for the last 6 months, both starting on 10/22/22.

Welcome and enjoy!

My Travels

Travel Transport

Calories Burned

Calories Burned vs Travel

Music

Music vs Travel

Summary

My 5 questions based on the data presented:

Q1. What are some similarities and differences in locations and duration of my trips?

Answer: All the states visited are on the ocean coast (except Pennsylvania). The further I go, the longer my trips are.

Q2. What is my preferences order for transportation methods?

Answer: Plane is the most popular since many trips are would take much longer by other options. Car is the second best option (used to get to relatively close places). Train is the least popular and is good for mid-length distances.

Q3. Do I mostly meet the daily burning calories goal?

Answer: Looking at the plot, we can see that most days I burn the calories set in the goal. If I haven’t reduced the goal limit in the beginning, I would have a harder time consistently reaching the goal.

Q4. Is there any pattern in listening to the music?

Answer: Looking at the Music slide, I can’t clearly notice a pattern. There are some days when I don’t listen to it at all, and then there are some when I listen a lot. But mostly it looks pretty random.

Q5. Looking at the charts with Calories Burned vs Travel and Music Streamed vs Travel, can we notice anything interesting?

Answer: When looking at the Calories Burned vs Travel chart, I notice that during my trips there is typically a spike in calories burn. It makes sense since I like hiking, walking around the city when traveling. Music Streaming vs Travel plot also gives some additional perspective - I can see that during my travel there is often a drop in music streaming.

Well, that was fun!

Please feel free to leave a comment :)

---
title: "Quantified Self"
author: "Alexander Kurochkin"
date: "04/25/2023"
output: 
  flexdashboard::flex_dashboard:
    storyboard: true
    source: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(plotly)
library(dplyr)
library(lubridate)

setwd('C:/Users/kuroc/Documents/From Lenovo Desktop/Univer/HU/ANLY 512 - Data Visualization/Final Project (Quantified Self)/Final Data/')

calories = read.csv(file.path(getwd(),'Steps Data.csv'))
travel = read.csv(file.path(getwd(),'Travel Data.csv'))
music = read.csv(file.path(getwd(),'Music Data.csv'))

#I can talk about travel and related things like steps count (travel vs no travel), transportation type (plane, train, car, ferry), states and cities/towns, attractions visited, coffee spots, music playing hours (travel vs no travel)...
```

### Introduction

In this final project, Professor Alan Hitch introduced me to the Quantified Self movement. I am going to visualize some aspects of my life based on the data I collected.

I have three datasets with calories burn data starting on 11/13/22, travel data for the last 6 months (2+ days-long trips), and music play data for the last 6 months, both starting on 10/22/22.

Welcome and enjoy!

### My Travels

```{r}
travel$hover <- with(travel, paste(ToCity, ToState, "<br>", StartDate, "-",EndDate, "<br>Got here by", MainTransport, "from", FromCity, FromState))

l <- list(color = toRGB("white"), width = 2)

g <- list(
  scope = 'usa',
  projection = list(type = 'albers usa'),
  showlakes = TRUE,
  lakecolor = toRGB('white')
)

fig <- plot_geo(travel, locationmode = 'USA-states')
fig <- fig %>% add_trace(
    z = ~Duration, text = ~hover, locations = ~ToState,
    zmin=0, zmax=5,
    color = ~Duration, colors = 'Purples'
  )
fig <- fig %>% colorbar(title = "<b>Duration in days</b>")
fig <- fig %>% layout(
    title = 'My Trips For The Last 6 Months<br>(At Least 2 Days-Long)',
    geo = g
  )

fig
```

### Travel Transport

```{r}
ggplot(travel, aes(x=MainTransport, fill = MainTransport)) +
  geom_bar(stat="count")+labs(title="Travel Transportation Picks",subtitle = "10/22/22 - 04/22/23",
        x ="Transportation Type", y = "Trips Count",fill="Transport")

```

### Calories Burned

```{r}
fig3 <- plot_ly(calories, x = ~mdy(Date), y = ~CaloriesBurned, name = 'Burned', type = 'scatter', mode = 'lines',
        line = list(color = 'rgb(205, 12, 24)', width = 2))
fig3 <- fig3 %>% add_trace(y = ~CaloriesGoal, name = 'Goal', line = list(color = 'rgb(26, 118, 255)', width = 2, dash = 'dash'))

fig3 <- fig3 %>% layout(title = "Calories Burned vs Calories Burn Goal",
         xaxis = list(title = "Dates"),
         yaxis = list(title = "Calories"),
         hovermode = 'x',
         legend = list(title = list(text = "<b>Calories</b>")))
fig3
```

### Calories Burned vs Travel

```{r}
fig3b <- fig3

rectangle <- list(
  type = "rect",
  fillcolor = "purple",
  line = list(color = "purple"),
  opacity = 0.5,
  xref = "x",
  yref = "y"
)

rects <- list()
for (i in 1:nrow(travel)) {
  rectangle[["x0"]] <- mdy(travel$StartDate[i])
  rectangle[["x1"]] <- mdy(travel$EndDate[i])
  rectangle[["y0"]] <- 0
  rectangle[["y1"]] <- max(calories$CaloriesBurned)
  rects <- c(rects, list(rectangle))
}

fig3b <- layout(fig3b, title = 'Calories Burned vs Travel',
             shapes = rects) 
for (i in 1:nrow(travel)) {  
  fig3b <- fig3b %>% add_annotations(x = (mdy(travel$EndDate[i])-(mdy(travel$EndDate[i])-mdy(travel$StartDate[i]))/2), 
                   y = max(calories$CaloriesBurned)-50,
                   xref = "x",
                   yref = "y",
                   text = "Trip",
                   font = list(color = '#000000'), showarrow = F)
}

fig3b
```

### Music

```{r}
mus_summary <- music %>%
  filter(!is.na(PlayDuration)) %>%
  group_by(Date) %>% 
  summarise(DailyDuration = sum(as.numeric(PlayDuration)))

fig4 <- plot_ly(mus_summary,x = ~mdy(Date), y = ~(DailyDuration/60000), type = 'bar',
        marker = list(color = 'rgb(205, 12, 24)'))
fig4 <- fig4 %>% layout(title = 'Daily Music Streaming Times In Minutes',
         hovermode = 'x',
         xaxis = list(
           title = "",
           tickfont = list(
             size = 14,
             color = 'rgb(107, 107, 107)')),
         yaxis = list(
           title = 'Minutes Streamed',
           titlefont = list(
             size = 16,
             color = 'rgb(107, 107, 107)'),
           tickfont = list(
             size = 14,
             color = 'rgb(107, 107, 107)')),
         legend = list(x = 0, y = 1, bgcolor = 'rgba(255, 255, 255, 0)', bordercolor = 'rgba(255, 255, 255, 0)'),
         barmode = 'group', bargap = 0.15, bargroupgap = 0.1)

fig4
```

### Music vs Travel

```{r}
fig4b <- fig4

rects <- list()
for (i in 1:nrow(travel)) {
  rectangle[["x0"]] <- mdy(travel$StartDate[i])
  rectangle[["x1"]] <- mdy(travel$EndDate[i])
  rectangle[["y0"]] <- 0
  rectangle[["y1"]] <- max(mus_summary$DailyDuration)/60000
  rects <- c(rects, list(rectangle))
}

fig4b <- layout(fig4b, title = 'Music Streaming vs Travel',
             shapes = rects) 
for (i in 1:nrow(travel)) {  
  fig4b <- fig4b %>% add_annotations(x = (mdy(travel$EndDate[i])-(mdy(travel$EndDate[i])-mdy(travel$StartDate[i]))/2), 
                   y = max(mus_summary$DailyDuration)/60000-20,
                   xref = "x",
                   yref = "y",
                   text = "Trip",
                   font = list(color = '#000000'), showarrow = F)
}

fig4b
```

### Summary

My 5 questions based on the data presented:

Q1. What are some similarities and differences in locations and duration of my trips?

Answer: All the states visited are on the ocean coast (except Pennsylvania). The further I go, the longer my trips are.

Q2. What is my preferences order for transportation methods?

Answer: Plane is the most popular since many trips are would take much longer by other options. Car is the second best option (used to get to relatively close places). Train is the least popular and is good for mid-length distances.

Q3. Do I mostly meet the daily burning calories goal?

Answer: Looking at the plot, we can see that most days I burn the calories set in the goal. If I haven't reduced the goal limit in the beginning, I would have a harder time consistently reaching the goal.

Q4. Is there any pattern in listening to the music?

Answer: Looking at the Music slide, I can't clearly notice a pattern. There are some days when I don't listen to it at all, and then there are some when I listen a lot. But mostly it looks pretty random.

Q5. Looking at the charts with Calories Burned vs Travel and Music Streamed vs Travel, can we notice anything interesting?

Answer: When looking at the Calories Burned vs Travel chart, I notice that during my trips there is typically a spike in calories burn. It makes sense since I like hiking, walking around the city when traveling. Music Streaming vs Travel plot also gives some additional perspective - I can see that during my travel there is often a drop in music streaming.

Well, that was fun!

Please feel free to leave a comment :)