Error with analysing ridership data by type and weekday

Hi eveyone,
Let me quickly give a background on this matter. I have been on this data for morethan four weeks (owing to working full time) and I have not been able to get past 'analyse ridership data by type and weekday!' I am working on the "Cyclist Ride Data" as part of requirements for - Google Data Analytics capstone project.
I started the cleaning process on RDesktop but encountered technical hitches and had to start the process all over on rstudio-cloud. Because of the size of the data and for the fact that i am using a free Rstudio sub (1Gb RAM max capacity) the cleaning could not be completed. I am back on the RStudio Desktop 'version 4.3.1. - CRAN (UK).' Without wasting your time, i have installed packages and loaded libraries (required) for the analysis.

analyze ridership data by type and weekday

mutate(weekday = wday(started_at, label = TRUE)) %>%
group_by(member_casual, weekday) %>%
summarise(number_of_rides = n()
,average_duration = mean(ride_length)) %>%
arrange(member_casual, weekday)

Here is a screen shot of the error message:

Note: I am a R-Pprogramming newbie.

The %>% operator (the magrittr pipe) can't be found because it's not in namespace (the term for recognizable objects). This can happen if the related package hasn't been installed and if it hasn't been loaded. The pipe is in the {magrittr} package. Installing packages is done the same way that you have done with {lubridate} and the others at the top of the screen. But that's not enough. You must also invoke it with

library(magrittr)

directly or, indirectly, with

library(dplyr)

which is the usual option.

One way to pick up the most often needed packages is with

install.packages("tidyverse") # needed only once
library(tidyverse)

which will load {dplyr} (including the magrittr pipe) and many, although not all, of the other packages you will be using routinely during the course.

When you come back with other questions, use a reprex (see the FAQ) to illustrate problems rather than a screenshot. You're likely to attract more answers that way.

  stringsAsFactors = FALSE,
       ride_length = c(446, 1048, 252, 357, 1007),
     member_casual = c("member", "member", "member", "member", "member"),
       day_of_week = c("Monday", "Monday", "Monday", "Monday", "Monday")
)> all_trips_v2 %>%
+ mutate(weekday = wday(started_at, label = TRUE)) %>%
+ group_by(member_casual, weekday) %>%
+ summarise(number_of_rides = n()
+ ,average_duration = mean(ride_length)) %>%
+ arrange(member_casual, weekday)
Error in all_trips_v2 %>% mutate(weekday = wday(started_at, label = TRUE)) %>%  : 
  could not find function "%>%"```

# I remember you once shared with me how to extract the data.frame. Apologies for the drawback.
# I will explore the "library(magrittr)" as you have suggested

#> this is the appropraite data.frame (disregard the earlier one)

  stringsAsFactors = FALSE,
     rideable_type = c("6251", "6226", "5649", "4151", "3270"),
       day_of_week = c("Monday", "Monday", "Monday", "Monday", "Monday")
)> all_trips_v2 %>%
+ mutate(weekday = wday(started_at, label = TRUE)) %>%
+ group_by(member_casual, weekday) %>%
+ summarise(number_of_rides = n()
+ ,average_duration = mean(ride_length)) %>%
+ arrange(member_casual, weekday)
Error in all_trips_v2 %>% mutate(weekday = wday(started_at, label = TRUE)) %>%  : 
  could not find function "%>%"```

Probably you also require

library(dplyr)

@technocrat you have been very helpful.

I will give it a try and let you know the outcome.

Thank you!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.