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

@kassambara kassambara commented May 24, 2020

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

@kassambara kassambara commented May 24, 2020

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)

@kassambara kassambara closed this May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.