0

See a simple code

library(reactable)
data = data.frame(x = c('a','a','b','b'),
                  values = c(NA,5,3,NA))
reactable(data,
          groupBy = 'x')

enter image description here

Is it possible to count only the lines which aren't NA?

I want to see a(1), b(1) instead

Arkadi w
  • 129
  • 22

1 Answers1

0

You can remove the NAs with na.omit()

data = data.frame(x = c('a','a','b','b'),
                  values = c(NA,5,3,NA))
data = na.omit(data)
reactable(data,
          groupBy = 'x')
Ray
  • 2,008
  • 14
  • 21
  • I need the NA in the table. – Arkadi w May 01 '21 at 13:09
  • I am not a reactable power user and a quick glimpse at the documentation does not give an immediate solution. What I can see from the documentation that the number displayed is the count of members. Since you group by x, reactable() will find 2 a's and 2 b's. I have no idea about your usecase. However keeping the NAs in your table makes reactable correctly "group" and count the members per group. What is the benefit of "manipulating" the count of members and when someone expands the group sees additional rows? Maybe what you are looking for is not reactable? – Ray May 01 '21 at 15:05
  • I need NA values in my data. If I could remove the (2) at all that would also be a nice solution – Arkadi w May 01 '21 at 17:57
  • Given this SO question this is not possible today: https://stackoverflow.com/questions/62304095/suppress-parenthesis-in-r-reactable-group-aggregation. I keep my fingers crossed for you that this feature will be implemented in a not too distant future. – Ray May 02 '21 at 07:44