In your project, I have managed to get a pipeline working using this code:
library(tidyverse)
library(janitor)
library(lubridate)
daily_activity <- read_csv("/cloud/BellaBeat/dailyActivity_merged.csv")
daily <- daily_activity %>%
clean_names() %>%
mutate(activity_date=mdy(activity_date)) %>%
rename(date = activity_date,
steps = total_steps) %>%
select(-c(5:10))
head(daily)
To unpack what is happening here:
-
janitor::clean_names makes the column names of your data frame "snake_case" (easier to use!)
-
dplyr::mutate is converting the activity_date column to a date using the function lubridate::mdy
-
dplyr::rename is renaming the column headers, using the syntax new_name = old_name
-
dplyr::select is dropping the fifth through the tenth columns
When writing a script, it is not typical to include install.packages as you will not want to re-do that with every re-run of a script. You install once, you load (using library) every time.