Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add observation number in ggboxplot or similar functions? #598

Open
ShixiangWang opened this issue Mar 27, 2024 · 0 comments
Open

Add observation number in ggboxplot or similar functions? #598

ShixiangWang opened this issue Mar 27, 2024 · 0 comments

Comments

@ShixiangWang
Copy link

Expected behavior

A new feature that implemented in the ggboxplot or similar function to support the view of the observation number in the plot. It's useful in many cases for publication-ready plots.

Actual behavior

I cannot find corresponding options.

Steps to reproduce the problem

# Load data
data("ToothGrowth")
df <- ToothGrowth

# Basic plot
# +++++++++++++++++++++++++++
# width: change box plots width
ggboxplot(df, x = "dose", y = "len", width = 0.8)

Is it possible to add a new option, e.g., show_number to show the observation number alongside the group text? So the 0.5 would be 0.5 (n=20) or similar. If there are better position for showing the number could also be considered.

ggboxplot(df, x = "dose", y = "len", width = 0.8, show_number = TRUE)
> library(dplyr)

Attaching package: ‘dplyr’

The following object is masked from ‘package:Biobase’:

    combine

The following objects are masked from ‘package:BiocGenerics’:

    combine, intersect, setdiff, union

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

> df |> group_by(dose) |> tally()
# A tibble: 3 × 2
   dose     n
  <dbl> <int>
1   0.5    20
2   1      20
3   2      20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant