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

ggerrorplot: add option to treat x as numeric axis #280

Closed
kassambara opened this issue May 24, 2020 · 1 comment
Closed

ggerrorplot: add option to treat x as numeric axis #280

kassambara opened this issue May 24, 2020 · 1 comment

Comments

@kassambara
Copy link
Owner

The current default of ggerrorplot() is to always treat x as a factor.

The option numeric.x.axis should be added; logical value. If TRUE, x axis will be treated as numeric. Default is FALSE.

@kassambara
Copy link
Owner Author

suppressPackageStartupMessages(library(ggpubr))

# Demo data
mi_df <- data.frame(
  "month" = as.numeric(rep(c(0,1,2,12,15,48),30)) , 
  "sust" = as.factor(rep(c(rep(c("A","B"), each=6)), 15)),
  "vble" = as.numeric(rnorm(180)))

# Error plot: x-axis treated as factor (default)
ggerrorplot(
  mi_df, x = "month", y = "vble", 
  desc_stat = "mean_sd", color = "sust", palette = c("black","grey"),
  title= "smt", ylab= "vble",             
  position = position_dodge(0.3)   
  )

# Using numeric x axis: numeric.x.axis = TRUE
ggerrorplot(
  mi_df, x = "month", y = "vble", 
  desc_stat = "mean_sd", color = "sust", palette = c("black","grey"),
  title= "smt", ylab= "vble",             
  position = position_dodge(0.3),
  numeric.x.axis = TRUE
)

Created on 2020-05-24 by the reprex package (v0.3.0.9001)

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