"could not find function %>%<-", Was working fine then it stop working

Has this happened to anyone, I was recently using it just fine. The pipe function was working just fine. Then all of a sudden R starts to slow down and it stops working completely. Provides me with a could not find function "%>%" Error which does not make sense since I was just using it. I have closed R reloaded packages and still nothing.

Packages and Libraries are of the following:

`install.packages("tidyverse")

install.packages("magrittr")

library("dplyr")

library("readr") library("lubridate")

library("tidyr")

library("stringr")

library("tidyverse")

Code chunk:

heartrate_sec<-data.frame(
 Id =c(336,339,342),
 Time=c(4/12/2016 7:21:00 AM, 4/12/2016 7:21:05 AM,4/12/2016 
  7:21:10 AM) 

new_heartrate <- heartrate_sec %>%  separate(Time 
,c("date","time"),sep=" ", extra="merge")

The way I understood this was this will allow me to separate the column "Time" into

date =c(4/12/2016,4/12/2016,4/12/2016)
time =c(7:21:00 AM, 7:21:05 AM, 7:21:10 AM) 

Where extra="merge" will merge the AM or anything else that is not time and date

But unfortunately, that didn't work so I received the following error

Error in heartrate_sec %>% separate(Time, c("date", "time"), sep = " ", : could not find function "%>%"

When I tried it in both cloud R and in a new project based on my desktop version of R and proceeded to run the entire code chunk again but with a time format.

heartrate_sec %>% separate(Time,c("Date","Time"),sep=" ",extra 
= "merge") %>% mutate(out = format(Time, format="%H:%M:%S"))

I received the same thing now with an R Session Aborted R encountered a fatal error. The session was terminated.

I do want to point out that I have tried this code chunk previously and it worked just fine before but now I am a bit clueless as to what is wrong I hope I have explained it correctly. I am fairly new to R so please bear with me.

Hi! Thanks for the welcome!

Yes, that was one of the 3 problems that I was facing. I needed to call
library(magrittr)

The function did in fact work in a previous R environment with a much smaller data. frame . This brought me to realize
that
data.frame heartrate_sec
contains 2483658 objects of 3 variables.
I believe it was too big for the function to work, thus the reason R kept crashing but correct me if I am wrong.

A workaround was to break it down into only the data I needed and then separate the columns. Which turn out perfectly.

Hopefully, that fix all of the issues.
Thanks again for the help, I really do appreciate it.

The size of the data frame doesn't have anything to do with the pipe, although the size might have interacted with the functions you are piping into.

So that I can have a better understanding and avoid this in the future can you explain this a little bit more, please?

This part
"Although the size might have interacted with the functions you are piping into"

Thanks in advance!

The pipe is just "syntactic sugar." It makes it easier to write clear code but doesn't change functionality. (Writing clear code being uber important.)

Suppose you have a function that takes two arguments, foo(a,b). Then
a %>% foo(b) is translated exactly into foo(a,b). The pipe is just a nice way of providing an argument into a function.

Oh ok, I understand.
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.