Learn R Programming

edar (version 0.0.6)

ggxy: XY scatter plot wrapper

Description

Create basic XY scatter plot for quick data exploration. Default to show Pearson correlation coefficient with p-value using ggpubr::stat_cor. For more complex plots, it is recommended to use ggplot2::ggplot2 directly.

Usage

ggxy(
  d,
  x,
  y,
  ...,
  lm = TRUE,
  se = TRUE,
  cor = TRUE,
  pv = NULL,
  nsub = TRUE,
  legend = TRUE,
  asp = 1
)

Value

A ggplot object.

Arguments

d

<dfr> A data frame.

x, y

<var> Variables for x- and y-axis as unquoted names.

...

Arguments to pass to ggplot2::aes for additional mapping.

lm

<lgl> TRUE to add regression line from linear model.

se

<lgl> TRUE to show standard error with the regression line.

cor

<lgl> TRUE to show Pearson correlation coefficient with p-value.

pv

<dbl> Precision for the p-value, e.g., 0.001 to show 3 decimal places.

nsub

<lgl> Show number of observations.

legend

<lgl> TRUE to show legend.

asp

<num> For aspect.ratio in ggplot2::theme.

See Also

ggpubr::stat_cor

Examples

Run this code
mtcars |> ggxy(wt,hp)
mtcars |> ggxy(wt,hp,col=factor(gear))
mtcars |> ggxy(wt,hp,col=factor(gear),legend=FALSE)
mtcars |> ggxy(wt,hp,col=factor(gear),pch=factor(am))
mtcars |> ggxy(wt,hp,nsub=FALSE)
mtcars |> ggxy(wt,hp,pv=0.001)
mtcars |> ggxy(wt,hp,lm=FALSE)
mtcars |> ggxy(wt,hp,se=FALSE)
mtcars |> ggxy(wt,hp,cor=FALSE)

Run the code above in your browser using DataLab