R Shiny Error: no applicable method for 'filter_' applied to an object of class "c('reactiveExpr','reactive')"

0 votes

I'm new to R shiny, i try to add a new column using a condition, but the shiny app object throws this error. Can someone help.

In the below code im trying to display number of  games that have a tied match for each team in the season.

My code

matches_played = reactive({ matches_year() %>% filter(match_id < playoff()) }) # playoff here is match-id before qualifiers start.
t1 = reactive({ matches_played() %>% group_by(team1) %>% summarise(count = n()) })
t2 = reactive({ matches_played() %>% group_by(team2) %>% summarise(count = n()) })
wl = reactive({ matches_played() %>% filter(winner != "") %>% group_by(winner) %>% summarise(no_of_wins = n()) })
playertable = reactive({ data.frame(Teams = t1()$team1, Played = t1()$count+t2()$count, Wins = wl()$no_of_wins) })
playertable_new = reactive({ playertable() %>% mutate(Teams = ifelse(Teams == tied()$team1|Teams == tied()$team2,1,0), Lost = Played-Wins-Tied, Points = wl()$no_of_wins*2) %>% arrange(-Wins) })
output$player_table = renderTable({ playertable_new() })

Aug 20 in Data Analytics by archana
82 views

1 answer to this question.

0 votes

The error could be because of using reactive variables without parenthesis.

Or you are filtering the wrong argument from the reactive variable.

In this line,

playertable_new = reactive({ playertable() %>% mutate(Teams = ifelse(Teams == tied()$team1|Teams == tied()$team2,1,0), Lost = Played-Wins-Tied, Points = wl()$no_of_wins*2) %>% arrange(-Wins) })

Try like this.

playertable()$Tied=reactive({ ifelse(Teams == tied()$team1|Teams == tied()$team2,1,0) })
playertable()$Lost=reactive({ playertable()$Played - playertable()$Won - playertable()$Tied  })

It would work.

answered Aug 21 by Cherukuri
• 25,900 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer

"no applicable method" Error in r programming

This is caused by using an object-oriented ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 40,460 points
70 views
0 votes
1 answer

Error saying "ERROR: Expected tag to be of type header" while creating a dashboard using shiny R

sliderInput("bins","number of breaks",1,100,50), this line should come under ...READ MORE

answered Nov 29, 2018 in Data Analytics by Maverick
• 10,040 points
279 views
0 votes
1 answer

Error saying "could not find function "shinyUI"" in shiny R

Its a small spelling mistake that you've ...READ MORE

answered Nov 28, 2018 in Data Analytics by Maverick
• 10,040 points
394 views
0 votes
1 answer

Error saying "could not find function dashboardPage" in shiny R

Include this line in the code: Library(shinydashboard) READ MORE

answered Nov 28, 2018 in Data Analytics by Maverick
• 10,040 points
227 views
0 votes
1 answer

R Shiny Error: Object of type 'closure' is not subsettable

The error you mentioned happens when you ...READ MORE

answered Aug 20 in Data Analytics by anonymous
• 25,900 points
51 views