ggsmatr: ggsmatr 'ggplot2' based SMATR plots

View source: R/ggsmatr.R

ggsmatrR Documentation

ggsmatr 'ggplot2' based SMATR plots

Description

Create a scatter plot based on the coefficients from (Standardised) Major Axis Estimation fit.

Usage

ggsmatr(data, groups , xvar , yvar, sma.fit)

Arguments

data

a dataframe.

groups

group variable.

xvar

x variable for drawing.

yvar

y variable for drawing.

sma.fit

an sma or ma object fitted in SMATR package.

Value

ggplot based plot of sma.

Examples

datafile <- system.file("iris.csv", package = "ggsmatr")
df.iris <- read.csv(datafile, encoding = "UTF-8")

library(ggsmatr)
library(ggplot2)
library(smatr)
fit = sma(Sepal.Length ~ Sepal.Width + Species, 
          data = df.iris,shift=TRUE, elev.test=TRUE)
#
ggsmatr(data =  df.iris, groups = "Species", 
        xvar =  "Sepal.Width", yvar = "Sepal.Length", 
        sma.fit =  fit) + 
theme(legend.position = "top", legend.title=element_blank())+ 
ylab("Sepal.Length")+ 
xlab("Sepal.Width")+ 
theme(legend.position = "top")



mariosandovalmx/ggsmatr documentation built on May 21, 2023, 3:40 p.m.