0

I am trying to develop a dashboard with flexdashboard. However, dplyr somehow does not work in the chunk and gives an error.

My code:

Total = data %>% dplyr::filter(CONDITION == 'A') %>% nrow()
valueBox(value = Total ,icon = "fa-user-plus",caption = "Total",color = "green")




 Error in UseMethod("filter_") : no applicable method for 'filter_' applied to an object of class 
 "function" Calls: <Anonymous> ... <Anonymous> -> <Anonymous> -> filter.default -> filter_
 In addition: Warning messages:
 1: package 'flexdashboard' was built under R version 3.6.3 
 2: package 'dplyr' was built under R version 3.6.1 
 Execution halted`

What I have tried: 1.

  1. Updating dplyr
  2. Updating tidyverse
  3. Updating 'R'
  4. Printing the value directly (but as I wan to automate, I would need the code to work)
marine8115
  • 588
  • 3
  • 22
  • 1
    `filter` can't find `data` data frame hence it uses the `data` function from base R which generates the error _Error in UseMethod("filter_") : no applicable method for 'filter_' applied to an object of class "function"_ make sure `data` is available for `filter` and avoids using R reserved names like `data`; use e.g `data_flex` as a name for your data frame. – A. Suliman Apr 13 '20 at 08:48
  • Could you try data$CONDITION for the CONDITION part – Seyma Kalay Apr 13 '20 at 07:35

1 Answers1

0

I tried with my own data, check your dataset that you named "data"... if I do my own example below, I get no errors

 data <- iris
 Total = data %>% dplyr::filter(Species == 'setosa') %>% nrow()
Daniel_j_iii
  • 3,041
  • 2
  • 11
  • 27