install.packages(“tidyverse”)
install.packages(“lubridate”)
install.packages(“dplyr”)
install.packages(“ggplot2”)
install.packages(“tidyr”)
install.packages(“here”)
install.packages(“skimr”)
install.packages(“janitor”)
library(lubridate)
library(dplyr)
library(ggplot2)
library(tidyr) l
ibrary(here) l
ibrary(skimr)
library(janitor)
DailyActivity <- read_csv("mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16/dailyActivity_merged.csv")
Importing dataset of Daily Calories
DailyCalories <- read.csv("mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16/dailyCalories_merged.csv")Importing dataset of Intensities
DailyIntensities <-read.csv("mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16/dailyIntensities_merged.csv")Importing dataset of Heart Rate
HeartRate <- read.csv("heartrate_seconds_merged.csv")Importing dataset of Weight Log Info
WeightLog <-read.csv("mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16/weightLogInfo_merged.csv")Importing dataset of Sleep
sleepDay <-read.csv("mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16/sleepDay_merged.csv")found no duplications, errors in any files except for Sleep data.
removed duplicated rows found at 163, 225 and, 382 from column ‘SleepDay’ successfully using google spreadsheet.
for WeightLog data, Found one column ‘Fat’ with incomplete data so, I removed it.
WeightLog_Info <- WeightLog_Info[,-6]
for sleepDay data using separate( ) function to split the date and time.
sleep_day <- sleepDay %>%
separate(SleepDay, c("Date", "Time"), " ")
sleep_day
splitting date and time for WeightLog data too.
WeightLog_Info <- WeightLog %>%
separate(Date, c("Date", "Time"), " ")
WeightLog_Info
for DailyActivity:
DailyActivity %>%} select(TotalSteps, TotalDistance,SedentaryMinutes) %>% summary()
TotalSteps TotalDistance SedentaryMinutes Min. : 0 Min. : 0.000 Min.
: 0.0
1st Qu.: 3790 1st Qu.: 2.620 1st Qu.: 729.8
Median : 7406 Median : 5.245 Median :1057.5
Mean : 7638 Mean : 5.490 Mean : 991.2
3rd Qu.:10727 3rd Qu.: 7.713 3rd Qu.:1229.5
Max. :36019 Max. :28.030 Max. :1440.0
for sleep:
sleepDay %>%}
select(TotalSleepRecords, TotalMinutesAsleep, TotalTimeInBed) %>%
summary()
TotalSleepRecords TotalMinutesAsleep TotalTimeInBed
Min. :1.000 Min. : 58.0 Min. : 61.0
1st Qu.:1.000 1st Qu.:361.0 1st Qu.:403.0
Median :1.000 Median :433.0 Median :463.0
Mean :1.119 Mean :419.5 Mean :458.6
3rd Qu.:1.000 3rd Qu.:490.0 3rd Qu.:526.0
Max. :3.000 Max. :796.0 Max. :961.0
for DailyIntensities:
DailyIntensities %>%
select(VeryActiveMinutes, FairlyActiveMinutes, LightlyActiveMinutes, SedentaryMinutes) %>%
summary()
VeryActiveMinutes FairlyActiveMinutes LightlyActiveMinutes
Min. : 0.00 Min. : 0.00 Min. : 0.0
1st Qu.: 0.00 1st Qu.: 0.00 1st Qu.:127.0
Median : 4.00 Median : 6.00 Median :199.0
Mean : 21.16 Mean : 13.56 Mean :192.8
3rd Qu.: 32.00 3rd Qu.: 19.00 3rd Qu.:264.0
Max. :210.00 Max. :143.00 Max. :518.0
SedentaryMinutes
Min. : 0.0
1st Qu.: 729.8
Median :1057.5
Mean : 991.2
3rd Qu.:1229.5
Max. :1440.0
for DailyCalories:
DailyCalories %>%
select(Calories) %>%
summary()
Calories
Min. : 0
1st Qu.:1828
Median :2134
Mean :2304
3rd Qu.:2793
Max. :4900
for Weight:
WeightLog_Info %>%
select(WeightKg, BMI) %>%
summary()
WeightKg Fat
Min. : 52.60 Min. :22.00
1st Qu.: 61.40 1st Qu.:22.75
Median : 62.50 Median :23.50
Mean : 72.04 Mean :23.50
3rd Qu.: 85.05 3rd Qu.:24.25
Max. :133.50 Max. :25.00
NA's :65
Combined_data_inner <- merge(sleepDay, DailyActivity, by="Id")
n_distinct(Combined_data_inner$Id)
24
Combined_data_outer <- merge(sleepDay, DailyActivity, by="Id",all=TRUE) n_distinct(Combined_data_outer$Id)
33
What’s the relationship between steps taken in a day and sedentary minutes?
ggplot(data=DailyActivity, aes(x=TotalSteps, y=SedentaryMinutes)) + geom_point() + geom_smooth() + labs(title="Total Steps vs. Sedentary Minutes")
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
What’s the relationship between minutes asleep and time in bed?
ggplot(data=sleep_day, aes(x=TotalMinutesAsleep, y=TotalTimeInBed)) + geom_point()+ geom_smooth() + labs(title=" Minutes Asleep vs. Time in Bed Minutes")
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
What’s the relationship between steps taken and Calories ?
ggplot(data=DailyActivity, aes(x=TotalSteps, y=Calories)) +
geom_point() + geom_smooth() + labs(title="Total Steps vs. Calories")