You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
options(dplyr.summarise.inform=FALSE)
###### Get rid of info of dplyr when grouping: `summarise()` regrouping output by 'species' (override with `.groups` argument)###### https://rstats-tips.net/2020/07/31/get-rid-of-info-of-dplyr-when-grouping-summarise-regrouping-output-by-species-override-with-groups-argument/###### 2020/05/06###### dplyr, dplyr-1-0-0###### Hadley Wickham, Kirill Müller###### https://www.tidyverse.org/blog/2020/05/dplyr-1-0-0-last-minute-additions/
Loading and preprocessing the initialData
Load the initialData (i.e. read.csv())
Process/transform the initialData (if necessary) into a format suitable for your analysis
We can calculate the difference of the means and medians between imputed and original initial Data.
mean_diff<-imputed_mean-mean
## [1] 1411.959
median_diff<-imputed_median-median
## [1] 371.1887
Are there differences in activity patterns between weekdays and weekends?
library(lubridate)
day_of_week<-imputed_initialData %>%
mutate(
date= ymd(date),
weekday_or_weekend= case_when(wday(date) %in%2:6~"Weekday",
wday(date) %in% c(1,7) ~"Weekend")
) %>% select(-date) %>%
group_by(interval, weekday_or_weekend) %>%
summarise(
steps= mean(steps), .groups=NULL
)
###### summarise() and grouping ###### There's a common confusion about the result of summarise(). How do you think the result of the following code will be grouped?###### https://www.tidyverse.org/blog/2020/05/dplyr-1-0-0-last-minute-additions/
ggplot(day_of_week, aes(interval, steps)) +
geom_line(col="red") +
facet_wrap(~weekday_or_weekend, nrow=2) +
ggtitle("Average daily steps by type of date") +
xlab("5-Minute intervals") +
ylab("Average number of steps") +
theme( plot.title= element_text(hjust=0.5))