Error in UseMethod("group_by") : no applicable method for 'group_by' applied to an object of class "function" in r shiny

I am getting group_by error in r shiny but not in r studio.I am unable to understand and have tried few hit and trial solutions but they don't seem to work.Can anyone please help.

getwd()
setwd("C:/Users/Ritwik.Mohapatra/Documents/R")
oli_2020_2021_yearly_data<-read.csv("OLI_2020_2021_data.csv")
View(oli_2020_2021_yearly_data)
str(oli_2020_2021_yearly_data)

day<-substr(oli_2020_2021_yearly_data$Date.and.Time,1,3)

time<-substr(oli_2020_2021_yearly_data$Date.and.Time,12,19)

datemon<-substr(oli_2020_2021_yearly_data$Date.and.Time,5,10)

year<-substr(oli_2020_2021_yearly_data$Date.and.Time,20,25)

mon<-substr(oli_2020_2021_yearly_data$Date.and.Time,5,7)

oli_2020_2021_yearly_data$Date<-paste(datemon,year,sep="")

oli_2020_2021_yearly_data$Day<-day
oli_2020_2021_yearly_data$Time<-time
oli_2020_2021_yearly_data$Year<-year

oli_2020_2021_yearly_data<-oli_2020_2021_yearly_data[,-1]

oli_2020_2021_yearly_data$month = factor(mon, levels = month.abb)

names(oli_2020_2021_yearly_data)[names(oli_2020_2021_yearly_data) == "month"] <- "Month"

library(hms)
library(ggplot2)
library(shiny)
#library(plyr)
library(dplyr)

oli_2020_2021_yearly_data$Time<-as_hms(oli_2020_2021_yearly_data$Time)

#oli_2020_2021_yearly_data <- ldply (oli_2020_2021_yearly_data, data.frame)

login_logout_time_difference<-oli_2020_2021_yearly_data %>% group_by(User,Machine.Name,Application,Date,Day,Year,Month) %>%
mutate(difftime = Time - dplyr::lag(Time, default = Time[1]))

time_diff<-oli_2020_2021_yearly_data %>%
group_by(User,Machine.Name,Application,Date,Day,Month,Year) %>%
mutate(time.difference =ifelse(Login.Logout=="Logout",Time - lag(Time),NA))

group_by(id)%>%
mutate(duration = ifelse(event == "Logout", timestamp- lag(timestamp),NA))

Hi @ritm,
Looks like you are not piping a data frame into the last group_by() line:

time_diff<-oli_2020_2021_yearly_data %>%
group_by(User,Machine.Name,Application,Date,Day,Month,Year) %>%
mutate(time.difference =ifelse(Login.Logout=="Logout",Time - lag(Time),NA))

group_by(id)%>%
mutate(duration = ifelse(event == "Logout", timestamp- lag(timestamp),NA)) 

Either you are missing a pipe %>% or missing a data= argument.

Thanks.It somehow missed my notice.

This topic was automatically closed 7 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.