Package 'ggiraphExtra'

Title: Make Interactive 'ggplot2'. Extension to 'ggplot2' and 'ggiraph'
Description: Collection of functions to enhance 'ggplot2' and 'ggiraph'. Provides functions for exploratory plots. All plot can be a 'static' plot or an 'interactive' plot using 'ggiraph'.
Authors: Keon-Woong Moon [aut, cre]
Maintainer: Keon-Woong Moon <[email protected]>
License: GPL-3
Version: 0.3.0
Built: 2024-11-25 03:39:36 UTC
Source: https://github.com/cardiomoon/ggiraphextra

Help Index


Add value labels to the data.frame

Description

Add value labels to the data.frame

Usage

addLabelDf(data, mapping = NULL)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.


Browser market share 2011

Description

A phony dataset measuring browser market share

Usage

browsers

Format

A data.frame with 12 rows and 3 columns

browser

browser

version

browser version

share

market share, in percentage


The radar coordinate system is a modification of polar coordinate system, commonly used for radar chart

Description

The radar coordinate system is a modification of polar coordinate system, commonly used for radar chart

Usage

coord_radar(theta = "x", start = 0, direction = 1)

Arguments

theta

variable to map angle to (x or y)

start

offset of starting point from 12 o'clock in radians

direction

1, clockwise; -1, counterclockwise


extract variable name from mapping, aes

Description

extract variable name from mapping, aes

Usage

getMapping(mapping, varname)

Arguments

mapping

aesthetic mapping

varname

variable name to extract

Value

variable name in character

Examples

require(ggplot2)
mapping=aes(colour=sex)
mapping=aes(x=c(Sepal.Length,Sepal.Width,Petal.Length,Petal.Width))
getMapping(mapping,"colour")
getMapping(mapping,"x")

Make an interactive plot for an ANCOVA model

Description

Make an interactive plot for an ANCOVA model

Usage

ggAncova(x, ...)

## Default S3 method:
ggAncova(x, mapping, use.label = TRUE, use.labels = TRUE, ...)

## S3 method for class 'formula'
ggAncova(x, data, ...)

## S3 method for class 'lm'
ggAncova(x, label = NULL, digits = 1, interactive = FALSE, ...)

Arguments

x

an object

...

additional arguments passed to the generic function

mapping

Set of aesthetic mappings created by aes or aes_.

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

data

a data.frame

label

A character string of column name be assigned to the label

digits

An integer indicating the number of decimal places

interactive

A logical value. If TRUE, an interactive plot will be returned

Methods (by class)

  • default: Make an interactive plot for an ANCOVA model

  • formula: Make an interactive plot for an ANCOVA model

  • lm: Make an interactive plot for an ANCOVA model

Examples

require(moonBook)
require(ggplot2)
require(ggiraph)
ggAncova(radial,aes(age,NTAV,color=sex),interactive=TRUE)
fit=lm(NTAV~age+HBP,data=radial)
ggAncova(fit,interactive=TRUE)
ggAncova(NTAV~age+DM,data=radial)

Draw an interactive area plot

Description

Draw an interactive area plot

Usage

ggArea(
  data,
  mapping,
  position = "stack",
  palette = "Blues",
  reverse = TRUE,
  alpha = 0.4,
  size = 0.3,
  use.label = TRUE,
  use.labels = TRUE
)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

position

Either "stack" or "fill"

palette

A character string indicating the color palette

reverse

If true, reverse palette colors

alpha

Transparency

size

Line size

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

Value

An area plot

Examples

require(gcookbook)
require(ggplot2)
ggArea(uspopage,aes(x=Year,y=Thousands,fill=AgeGroup))
ggArea(uspopage,aes(x=Year,y=Thousands,fill=AgeGroup),position="fill")

Draw an interactive barplot

Description

Draw an interactive barplot

Usage

ggBar(
  data,
  mapping,
  stat = "count",
  position = "stack",
  palette = NULL,
  horizontal = FALSE,
  yangle = 0,
  xangle = 0,
  maxylev = 6,
  addlabel = FALSE,
  labelsize = 5,
  polar = FALSE,
  reverse = FALSE,
  use.label = TRUE,
  use.labels = TRUE,
  interactive = FALSE,
  ...
)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

stat

The statistical transformation to use on the data for this layer, as a string c("count","identity")

position

Position adjustment. One of the c("fill","stack","dodge")

palette

A character string indicating the color palette

horizontal

A logical value. If TRUE,a horizontal bar plot will be returned

yangle

An integer. The value will be used adjust the angle of axis.text.y

xangle

An integer. The value will be used adjust the angle of axis.text.x

maxylev

integer indicating threshold of unique value to be treated as a categorical variable

addlabel

A logical value. If TRUE, label will be added to the plot

labelsize

label size

polar

A logical value. If TRUE, coord_polar() function will be added

reverse

If true, reverse palette colors

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

interactive

A logical value. If TRUE, an interactive plot will be returned

...

other arguments passed on to geom_bar_interactive.

Value

An interactive barplot

Examples

require(moonBook)
require(ggplot2)
require(ggiraph)
require(plyr)
ggBar(acs,aes(x=Dx,fill=smoking),interactive=TRUE,width=1,colour="white",size=0.2,polar=TRUE)
ggBar(acs,aes(x=Dx,fill=smoking),position="fill",addlabel=TRUE,horizontal=TRUE,width=0.5)
ggBar(acs,aes(x=Dx,fill=smoking),position="dodge",interactive=TRUE,addlabel=TRUE)
ggBar(acs,aes(x=Dx,fill=smoking),position="fill",addlabel=TRUE)
ggBar(rose,aes(x=Month,fill=group,y=value),stat="identity",polar=TRUE,palette="Reds",width=1,
      color="black",size=0.1,reverse=TRUE,interactive=TRUE)

Draw boxplots of a data.frame

Description

Draw boxplots of a data.frame

Usage

ggBoxplot(
  data,
  mapping = NULL,
  rescale = FALSE,
  horizontal = FALSE,
  interactive = FALSE,
  addMean = TRUE,
  position = 0.9,
  use.label = TRUE,
  use.labels = TRUE,
  ...
)

Arguments

data

a data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

rescale

if true, rescale the data.frame

horizontal

if true, horizontal boxplots will be made

interactive

A logical value. If TRUE, an interactive plot will be returned

addMean

Whether add mean point on the plot

position

An integer. Uses as argument of position_dodge()

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

...

other arguments passed on to geom_boxplot_interactive

Examples

require(ggplot2)
require(ggiraph)
require(reshape2)
ggBoxplot(mtcars,rescale=TRUE)
ggBoxplot(mtcars,aes(x=c(mpg,cyl,disp,hp,drat),color=am),rescale=TRUE)
ggBoxplot(mtcars,aes(x=c(mpg,cyl,disp,hp,drat)),rescale=TRUE)
ggBoxplot(mtcars,rescale=TRUE,interactive=TRUE)
ggBoxplot(mtcars,horizontal=TRUE,interactive=TRUE)

Make an interactive catepillar plot

Description

Make an interactive catepillar plot

Usage

ggCatepillar(
  data,
  mapping,
  errorbar = "se",
  interactive = FALSE,
  digits = 1,
  flip = FALSE,
  use.label = TRUE,
  use.labels = TRUE
)

Arguments

data

a data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

errorbar

which value is displayed with errorbar :"se" or "sd"

interactive

A logical value. If TRUE, an interactive plot will be returned

digits

An integer indicating the number of decimal places

flip

Logical. If TRUE, coord_flip() function is used to make a horizontal plot

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

Value

An interactive catepillar plot

Examples

require(moonBook)
require(ggiraph)
require(ggplot2)
ggCatepillar(acs,aes(Dx,age,color=HBP))
ggCatepillar(acs,aes(c(Dx,sex),age,color=HBP),interactive=TRUE,flip=TRUE,use.labels=FALSE)
ggCatepillar(acs,aes(age,height,color=sex),errorbar=FALSE,interactive=TRUE)

Draw an interactive choropleth map

Description

Draw an interactive choropleth map

Usage

ggChoropleth(
  data,
  mapping,
  map,
  palette = "OrRd",
  reverse = FALSE,
  color = "grey50",
  title = "",
  digits = 1,
  interactive = FALSE,
  ...
)

Arguments

data

a data.frame

mapping

Set of aesthetic mappings created by aes or aes_. Passed on geom_map_interactive. Required mappings are map_id and fill. Possible mapping is facet.

map

a map maybe a result of map_data()

palette

A palette name used for discrete fill var, Default value is "OrRd"

reverse

If true, reverse palette colors

color

A name of color of polygon, Default value is "grey50"

title

A title

digits

An integer indicating the number of decimal places

interactive

Logical. If positive an interactive map will be made

...

other arguments passed on to geom_map_interactive

Examples

#crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
#require(ggplot2)
#require(ggiraph)
#require(maps)
#require(mapproj)
#require(reshape2)
#require(RColorBrewer)
#states_map <- map_data("state")
#ggChoropleth(crimes,aes(fill=Murder,map_id=state),map=states_map,interactive=TRUE)
#ggChoropleth(crimes,aes(fill=c(Murder,Rape),map_id=state),map=states_map,interactive=TRUE)
#ggChoropleth(crimes,aes(map_id=state),map=states_map,palette="OrRd",interactive=TRUE)

Draw a cleveland dot plot

Description

Draw a cleveland dot plot

Usage

ggCLE(
  data,
  mapping,
  reorderByX = TRUE,
  no = NULL,
  start = 0.99,
  interactive = FALSE,
  decreasing = TRUE,
  use.label = TRUE,
  use.labels = TRUE,
  ...
)

Arguments

data

a data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

reorderByX

If true, the data is reordered by x variable

no

Number of data be drawn in plot

start

start point of x axis as ratio to minimum x variable

interactive

A logical value. If TRUE, an interactive plot will be returned

decreasing

Should the sort order be increasing or decreasing?

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

...

other arguments passed on to geom_point_interactive

Examples

require(ggplot2)
require(ggiraph)
ggCLE(data=mtcars,aes(x=mpg),decreasing=FALSE,interactive=TRUE)
ggCLE(data=mtcars,aes(x=mpg,color=am,facet=am),interactive=TRUE)
if(requireNamespace("gcookbook",quietly=TRUE)){
   require(gcookbook)
   ggCLE(data=tophitters2001,aes(x=avg,y=name,color=lg,facet=lg),no=30,interactive=TRUE)
}

Draw a heatmap of correlation test

Description

Draw a heatmap of correlation test

Usage

ggCor(
  data,
  what = 1,
  label = 0,
  colors = NULL,
  title = TRUE,
  mode = 2,
  digits = 2,
  interactive = FALSE,
  yreverse = TRUE,
  xangle = 45,
  yangle = 0,
  use.label = FALSE,
  ...
)

Arguments

data

A data.frame

what

if 1, correlation, if 2, partial correlation, if 3, semi-partial correlation

label

if 0, no label(default), if 1, use r value as label, if 2, use r value with significant mark as label

colors

colors for low, mid and high correlation values

title

if true, add title to the heatmap

mode

1 or 2

digits

The number of decimal place

interactive

A logical value. If TRUE, an interactive plot will be returned

yreverse

If true, reverse y axis

xangle

x-axis text angle

yangle

y-axis text angle

use.label

Logical whether or not use label in case of labelled data

...

further arguments to be passed to cor.test

Examples

require(mycor)
require(ggplot2)
require(ggiraph)
require(ppcor)
ggCor(iris,digits=3,label=3)
ggCor(iris,what=3,digits=3,label=3)
ggCor(iris,label=3,interactive=TRUE)
ggCor(mtcars,interactive=TRUE)
ggCor(mtcars,mode=2,interactive=TRUE)
ggCor(iris,method="pearson",interactive=TRUE)

Make a density plot with histogram

Description

Make a density plot with histogram

Usage

ggDensity(
  data,
  mapping,
  linecolor = "red",
  addhist = TRUE,
  use.label = TRUE,
  use.labels = TRUE
)

Arguments

data

a data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

linecolor

Color of density curve

addhist

Whether add histogram or not

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

Examples

require(ggplot2)
require(moonBook)
ggDensity(acs,aes(x=age))
ggDensity(acs,aes(x=age,color=sex,fill=sex),addhist=FALSE)
ggDensity(acs,aes(x=age,color=sex,fill=sex))
ggDensity(acs,aes(x=age,fill=sex),addhist=FALSE)
ggDensity(acs,aes(x=age,color=sex))

Draw a Donut plot

Description

Draw a Donut plot

Usage

ggDonut(
  data,
  mapping,
  addDonutLabel = TRUE,
  showRatio = TRUE,
  polar = TRUE,
  labelposition = 1,
  labelsize = 3,
  title = "",
  use.label = TRUE,
  use.labels = TRUE,
  alpha = 0.7,
  interactive = FALSE,
  palette = NULL,
  reverse = FALSE,
  xmin = 3,
  xmax = 4,
  start = 3 * pi/2,
  direction = 1,
  colour = "white",
  explode = NULL,
  explodePos = 0.5,
  ...
)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

addDonutLabel

A logical value. If TRUE, labels are added to the Donuts

showRatio

A logical value. If TRUE, Ratios are added to the DonutLabels

polar

A logical value. If TRUE, coord_polar() function will be added

labelposition

A number indicating the label position

labelsize

label size. default value is 3

title

Plot title

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

alpha

transparency of geom_rect

interactive

A logical value. If TRUE, an interactive plot will be returned

palette

A character string indicating the color palette

reverse

If true, reverse palette colors

xmin

minimum x position

xmax

maximum x position

start

offset of starting point from 12 o'clock in radians

direction

1, clockwise; -1, counterclockwise

colour

colour of geom_rect

explode

number of donuts to explode

explodePos

explode position

...

further arguments to be passed to geom_rect_interactive

Value

An interactive Pie and Donut plot

Examples

require(ggplot2)
require(ggiraph)
require(plyr)
ggDonut(browsers,aes(donuts=version,count=share))
ggDonut(browsers,aes(donuts=version,count=share),palette="Reds",explode=c(2,4,6),labelposition=0)

Draw a Wilkinson dot plot

Description

Draw a Wilkinson dot plot

Usage

ggDot(
  data,
  mapping,
  stackdir = "center",
  binaxis = "y",
  binwidth = 0.5,
  method = "dotdensity",
  position = 0.2,
  boxwidth = 0.25,
  boxfill = NULL,
  use.label = TRUE,
  use.labels = TRUE,
  ...
)

Arguments

data

a data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

stackdir

which direction to stack the dots. "up" (default), "down", "center", "centerwhole" (centered, but with dots aligned)

binaxis

The axis to bin along, "x" (default) or "y"

binwidth

When method is "dotdensity", this specifies maximum bin width. When method is "histodot", this specifies bin width. Defaults to 1/30 of the range of the data

method

"dotdensity" (default) for dot-density binning, or "histodot" for fixed bin widths (like stat_bin)

position

Position adjustment. If 0, no adjustment.

boxwidth

The width of boxplot

boxfill

Fill color of boxplot

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

...

other arguments passed on to geom_dotplot

Examples

require(ggplot2)
if(requireNamespace("gcookbook",quietly=TRUE)){ # for data heightweight
 require(gcookbook)
 ggDot(heightweight,aes(sex,heightIn,fill=sex),boxfill="white",binwidth=0.4)
 ggDot(heightweight,aes(heightIn))
 ggDot(heightweight,aes(x=heightIn,fill=sex))
}
require(moonBook) #for use data radial
ggDot(radial,aes(x=sex,y=height,fill=sex),boxfill="white",position=0,binwidth=1,boxwidth=1)
ggDot(radial,aes(x=height,fill=sex),binwidth=1)
ggDot(acs,aes(x=sex,y=age,color=sex))
ggDot(acs,aes(x=Dx,y=age,color=Dx))

Visualize the effect of interaction between two continuous independent variables on a response variable

Description

Visualize the effect of interaction between two continuous independent variables on a response variable

Usage

ggEffect(x, ...)

## Default S3 method:
ggEffect(x, mapping, use.label = TRUE, use.labels = TRUE, ...)

## S3 method for class 'formula'
ggEffect(x, data, ...)

## S3 method for class 'lm'
ggEffect(
  x,
  no = 1,
  probs = c(0.1, 0.5, 0.9),
  point = TRUE,
  xvalue = NULL,
  digits = 2,
  use.rownames = FALSE,
  interactive = FALSE,
  ...
)

Arguments

x

Object to ggEffect

...

additional arguments passed to the generic function

mapping

Set of aesthetic mappings created by aes or aes_.

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

data

A data.frame

no

an integer

probs

A vector of probability weights for obtaining the elements of the vector being sampled.Default value is c(0.10,0.5,0.90)

point

A logical value. If TRUE, draw points

xvalue

A numeric vector

digits

An integer indicating the number of decimal places

use.rownames

If TRUE, use rownames in label

interactive

A logical value. If TRUE, an interactive plot will be returned

Value

An interactive plot showing interaction

Methods (by class)

  • default: Visualize the effect of interaction between two continuous independent variables on a response variable

  • formula: Visualize the effect of interaction between two continuous independent variables on a response variable

  • lm: Visualize the effect of interaction between two continuous independent variables on a response variable

Examples

require(ggplot2)
require(ggiraph)
ggEffect(mtcars,aes(x=wt,y=mpg,color=hp))
ggEffect(mtcars,aes(x=wt,y=mpg,color=hp),interactive=TRUE)
require(moonBook)
ggEffect(acs,aes(x=height,y=weight,color=smoking))
ggEffect(acs,aes(x=height,y=weight,color=smoking),interactive=TRUE)
require(ggplot2)
require(ggiraph)
require(moonBook)
ggEffect(NTAV~age*smoking,data=radial)
require(moonBook)
require(ggplot2)
require(ggiraph)
fit=lm(age~sex*smoking,data=acs)
ggEffect(fit,interactive=TRUE)
ggEffect(radial,aes(x=age,y=NTAV,color=smoking))
ggEffect(radial,aes(x=age,y=NTAV,color=smoking),interactive=TRUE)

Make an interactive bar plot with error bar

Description

Make an interactive bar plot with error bar

Usage

ggErrorBar(
  data,
  mapping,
  interactive = FALSE,
  digits = 1,
  mode = 2,
  errorbar = "se",
  use.label = TRUE,
  use.labels = TRUE
)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

interactive

A logical value. If TRUE, an interactive plot will be returned

digits

An integer indicating the number of decimal places

mode

if 2, two-sided error bar will be displayed, if 1 one-sided errorbar will be displayed

errorbar

which value is displayed with errorbar :"se" or "sd"

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

Value

An interactive catepillar plot

Examples

require(ggplot2)
require(ggiraph)
ggErrorBar(mpg,aes(x=drv,y=cty))
ggErrorBar(mpg,aes(x=drv,y=hwy,color=cyl),mode=1,interactive=TRUE,errorbar="sd")

Make an interactive Heatmap

Description

Make an interactive Heatmap

Usage

ggHeatmap(
  data,
  mapping,
  stat = "count",
  palette = "Blues",
  reverse = FALSE,
  addlabel = FALSE,
  polar = FALSE,
  interactive = FALSE,
  yangle = 0,
  color = "grey50",
  size = 0.1,
  use.label = TRUE,
  use.labels = TRUE,
  ...
)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

stat

The statistical transformation to use on the data for this layer, as a string c("count","identity")

palette

A palette name used for discrete fill var, Default value is "Blues"

reverse

If true, reverse palette colors

addlabel

A logical value. If TRUE, label will be added to the plot

polar

A logical value. If TRUE, coord_polar() function will be added

interactive

A logical value. If TRUE, an interactive plot will be returned

yangle

A integer. The value will be used adjust the angle of axis.text.y

color

Color argument passed on to geom_rect_interactive.

size

Size argument passed on to geom_rect_interactive.

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

...

other arguments passed on to geom_rect_interactive.

Value

An interactive barplot

Examples

require(moonBook)
require(ggplot2)
require(ggiraph)
require(sjmisc)
ggHeatmap(acs,aes(x=Dx,y=smoking),addlabel=TRUE,interactive=TRUE)
ggHeatmap(acs,aes(x=sex,y=Dx,fill=age),addlabel=TRUE,interactive=TRUE)
ggHeatmap(rose,aes(x=Month,y=group,fill=value),stat="identity",addlabel=TRUE)
ggHeatmap(rose,aes(x=Month,y=group,fill=value),addlabel=TRUE)
ggHeatmap(taco,aes(x=AgeGroup,y=Filling,fill=Rating,facet=ShellType),color="grey50",stat="identity")

Draw Tukey Honest Significant Differences plot

Description

Draw Tukey Honest Significant Differences plot

Usage

ggHSD(tukey, no = 1, digits = 2, interactive = FALSE)

Arguments

tukey

A object of class "TukeyHSD", the result of TukeyHSD()

no

An integer specify the order of list

digits

integer indicating the number of decimal places

interactive

A logical value. If TRUE, an interactive plot will be returned

Value

A (interactive) ggplot

Examples

require(ggplot2)
fm1 <- aov(breaks ~ wool + tension, data = warpbreaks)
result=TukeyHSD(fm1, "tension", ordered = TRUE)
str(result)
ggHSD(result)
ggHSD(result,interactive=TRUE)

Make an interactive scatter and line plot

Description

Make an interactive scatter and line plot

Usage

ggPair(
  data,
  mapping = NULL,
  rescale = FALSE,
  idcolor = TRUE,
  horizontal = FALSE,
  use.label = FALSE,
  use.labels = TRUE,
  includeFactor = TRUE,
  includeAll = FALSE,
  interactive = FALSE
)

Arguments

data

a data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

rescale

if true, rescale the data.frame

idcolor

Logical. If TRUE, row numbers uses as a color variable

horizontal

Logical. If TRUE, coord_flip() function is used to make a horizontal plot

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

includeFactor

Logical. Whether or not include factor variables

includeAll

Logical. Whether or not include all variables

interactive

Logical. If TRUE, an interactive plot using girafe() function will be returned

Examples

require(ggplot2)
require(ggiraph)
require(sjmisc)
require(moonBook)
ggPair(iris,rescale=TRUE,horizontal=TRUE)
ggPair(acs,aes(colour=smoking),horizontal=TRUE,rescale=TRUE)
ggPair(radial,aes(color=male),horizontal=TRUE,rescale=TRUE)
ggPair(mtcars,horizontal=TRUE,rescale=TRUE)
ggPair(iris,rescale=TRUE,horizontal=TRUE,interactive=TRUE)
ggPair(iris,aes(color=Species),rescale=TRUE,interactive=TRUE)
ggPair(iris,aes(x=c(Sepal.Length,Sepal.Width),color=Species),horizontal=TRUE,interactive=TRUE)

Draw a pie plot

Description

Draw a pie plot

Usage

ggPie(
  data,
  mapping,
  addPieLabel = TRUE,
  showRatioPie = TRUE,
  showRatioPieAbove10 = TRUE,
  title = "",
  labelposition = 1,
  polar = TRUE,
  use.label = TRUE,
  use.labels = TRUE,
  interactive = FALSE
)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

addPieLabel

A logical value. If TRUE, labels are added to the Pies

showRatioPie

A logical value. If TRUE, Ratios are added to the PieLabels

showRatioPieAbove10

A logical value. If TRUE, labels are added to the Pies with ratio above 10.

title

Plot title

labelposition

A number indicating the label position

polar

A logical value. If TRUE, coord_polar() function will be added

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

interactive

A logical value. If TRUE, an interactive plot will be returned

Value

An interactive pie plot

Examples

require(ggplot2)
require(ggiraph)
require(plyr)
require(moonBook)
ggPie(data=browsers,aes(pies=browser,count=share))
ggPie(data=acs,aes(pies=Dx))

Draw a Pie and Donut plot

Description

Draw a Pie and Donut plot

Usage

ggPieDonut(
  data,
  mapping,
  addPieLabel = TRUE,
  addDonutLabel = TRUE,
  showRatioDonut = TRUE,
  showRatioPie = TRUE,
  showRatioPieAbove10 = TRUE,
  title = "",
  labelposition = 1,
  polar = TRUE,
  use.label = TRUE,
  use.labels = TRUE,
  interactive = FALSE
)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

addPieLabel

A logical value. If TRUE, labels are added to the Pies

addDonutLabel

A logical value. If TRUE, labels are added to the Donuts

showRatioDonut

A logical value. If TRUE, Ratios are added to the DonutLabels

showRatioPie

A logical value. If TRUE, Ratios are added to the PieLabels

showRatioPieAbove10

A logical value. If TRUE, labels are added to the Pies with ratio above 10.

title

Plot title

labelposition

A number indicating the label position

polar

A logical value. If TRUE, coord_polar() function will be added

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

interactive

A logical value. If TRUE, an interactive plot will be returned

Value

An interactive Pie and Donut plot

Examples

require(ggplot2)
require(ggiraph)
require(plyr)
require(moonBook)
ggPieDonut(acs,aes(pies=Dx,donuts=smoking))
ggPieDonut(acs,aes(pies=smoking))
ggPieDonut(browsers,aes(pies=browser,donuts=version,count=share))
ggPieDonut(browsers,aes(x=c(browser,version),y=share),interactive=TRUE)

Make an interactive scatterplot with regression line(s)

Description

Make an interactive scatterplot with regression line(s)

Usage

ggPoints(
  data,
  mapping,
  smooth = TRUE,
  se = TRUE,
  method = "auto",
  formula = y ~ x,
  fullrange = FALSE,
  level = 0.95,
  use.count = FALSE,
  maxfactorno = 6,
  digits = 2,
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  use.label = TRUE,
  use.labels = TRUE,
  tooltip = NULL,
  interactive = FALSE,
  ...
)

Arguments

data

a data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

smooth

Logical. Add regression lines to the scatter plot

se

Logical. display confidence interval around linear regression? (TRUE by default)

method

smoothing method (function) to use, eg. "lm", "glm", "gam", "loess", "rlm"

formula

formula to use in smoothing function, eg. y ~ x, y ~ poly(x, 2), y ~ log(x)

fullrange

should the fit span the full range of the plot, or just the data

level

level of confidence interval to use (0.95 by default)

use.count

Logical. If true use geom_count instead of geom_point_interactive

maxfactorno

An integer. Maximum unique number of a numeric vector treated as a factor

digits

integer indicating the number of decimal places

title

The text for plot title

subtitle

The text for plot subtitle

caption

The text for plot caption

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

tooltip

A character string of column name be included in tooltip. Default value is NULL

interactive

A logical value. If TRUE, an interactive plot will be returned

...

other arguments passed on to geom_point

Examples

require(ggplot2)
require(ggiraph)
require(plyr)
ggPoints(aes(x=wt,y=mpg,fill=am),data=mtcars)
ggPoints(aes(x=wt,y=mpg),data=mtcars)
ggPoints(aes(x=wt,y=mpg,fill=am),data=mtcars,method="lm",interactive=TRUE)
ggPoints(aes(x=wt,y=mpg,color=am),data=mtcars,interactive=TRUE)

Visualize predictions from the multiple regression models.

Description

Visualize predictions from the multiple regression models.

Usage

ggPredict(
  fit,
  colorn = 4,
  point = NULL,
  jitter = NULL,
  se = FALSE,
  show.summary = FALSE,
  colorAsFactor = FALSE,
  digits = 2,
  interactive = FALSE,
  ...
)

Arguments

fit

a model object for which prediction is desired.

colorn

Integer. Number of subgroups of color variables.

point

Logical. Whether or not draw each point

jitter

Logical. Whether or not jitter points

se

Logical. Whether or not draw se

show.summary

Logical. Whether or not show summary

colorAsFactor

Logical. Whether or not treat color variable as categorical variable

digits

An integer indicating the number of decimal places

interactive

A logical value. If TRUE, an interactive plot will be returned

...

additional arguments affecting the predictions produced.

Examples

require(moonBook)
require(ggplot2)
require(ggiraph)
require(plyr)
fit=lm(NTAV~age*weight,data=radial)
fit=lm(NTAV~age*weight*DM,data=radial)
fit=lm(NTAV~age+DM,data=radial)
ggPredict(fit,interactive=TRUE)
require(TH.data)
fit=glm(cens~pnodes*horTh,data=GBSG2,family=binomial)
ggPredict(fit,se=TRUE)
fit1=glm(cens~pnodes*age,data=GBSG2,family=binomial)
ggPredict(fit1)
ggPredict(fit1,colorn=100,jitter=FALSE,interactive=TRUE)
fit2=glm(cens~pnodes*age*horTh,data=GBSG2,family=binomial)
ggPredict(fit2,colorn=100,jitter=FALSE,interactive=TRUE)

Draw a radar chart

Description

Draw a radar chart

Usage

ggRadar(
  data,
  mapping = NULL,
  rescale = TRUE,
  legend.position = "top",
  colour = "red",
  alpha = 0.3,
  size = 3,
  ylim = NULL,
  scales = "fixed",
  use.label = FALSE,
  interactive = FALSE,
  ...
)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

rescale

A logical value. If TRUE, all continuous variables in the data.frame are rescaled.

legend.position

Legend position. One of c("top","bottom","left","right","none")

colour

A name of color to be assigned as a color variable

alpha

Any numbers from 0 (transparent) to 1 (opaque)

size

Point size

ylim

A numeric vector of length 2, giving the y coordinates ranges.

scales

should Scales be fixed ("fixed", the default), free ("free"), or free in one dimension ("free_x", "free_y")

use.label

Logical. Whether or not use column label

interactive

A logical value. If TRUE, an interactive plot will be returned

...

other arguments passed on to geom_point

Value

An interactive radar plot

Examples

require(ggplot2)
require(ggiraph)
require(plyr)
require(reshape2)
require(moonBook)
require(sjmisc)
ggRadar(data=iris,aes(group=Species))
ggRadar(data=mtcars,interactive=TRUE)
ggRadar(data=mtcars,aes(colour=am,facet=cyl),interactive=TRUE)
ggRadar(data=acs,aes(colour=Dx,facet=Dx))
ggRadar(iris,aes(x=c(Sepal.Length,Sepal.Width,Petal.Length,Petal.Width)))

Draw an interactive Rose plot

Description

Draw an interactive Rose plot

Usage

ggRose(data, mapping, palette = "Reds", color = "black", size = 0.1, ...)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

palette

A character string indicating the color palette

color

Bar colour

size

Bar size

...

other arguments passed on to geom_bar_interactive.

Value

An interactive Rose plot

Examples

require(moonBook)
require(ggplot2)
require(ggiraph)
require(plyr)
ggRose(rose,aes(x=Month,fill=group,y=value),stat="identity",interactive=TRUE)
ggRose(acs,aes(x=Dx,fill=smoking),interactive=TRUE)

Draw an interactive spinogram

Description

Draw an interactive spinogram

Usage

ggSpine(
  data,
  mapping,
  stat = "count",
  position = "fill",
  palette = "Blues",
  interactive = FALSE,
  polar = FALSE,
  reverse = FALSE,
  width = NULL,
  maxylev = 6,
  digits = 1,
  colour = "black",
  size = 0.2,
  addlabel = TRUE,
  labelsize = 5,
  minlabelgroup = 0.04,
  minlabel = 2,
  hide.legend = TRUE,
  ylabelMean = FALSE,
  sec.y.axis = FALSE,
  use.label = TRUE,
  use.labels = TRUE,
  labeller = NULL,
  facetbycol = TRUE,
  xangle = NULL,
  yangle = NULL,
  xreverse = FALSE,
  yreverse = FALSE,
  xlab = NULL,
  filllab = NULL,
  family = NULL,
  ...
)

Arguments

data

A data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

stat

The statistical transformation to use on the data for this layer, as a string c("count","identity")

position

Position adjustment. One of the c("fill","stack","dodge")

palette

A character string indicating the color palette

interactive

A logical value. If TRUE, an interactive plot will be returned

polar

A logical value. If TRUE, coord_polar() function will be added

reverse

If true, reverse palette colors

width

Bar width

maxylev

integer indicating threshold of unique value to be treated as a categorical variable

digits

integer indicating the number of decimal places

colour

Bar colour

size

Bar size

addlabel

A logical value. If TRUE, label will be added to the plot

labelsize

label size

minlabelgroup

minimal threshold of label group. Default is 0.04

minlabel

minimal threshold of label. Default is 2

hide.legend

A logical value. If TRUE, the legend is removed and y labels are recreated

ylabelMean

Logical. If TRUE, y axis labels are positioned at mean value.

sec.y.axis

Logical. If TRUE, secondary y axis is shown at the right side.

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

labeller

A function that takes one data frame of labels and returns a list or data frame of character vectors.

facetbycol

Logical. If TRUE, facet by column.

xangle

angle of axis label

yangle

angle of axis label

xreverse

Logical. Whether or not reverse x-axis

yreverse

Logical. Whether or not reverse y-axis

xlab

Label for x-axis

filllab

Label for fill aes

family

font family

...

other arguments passed on to geom_rect_interactive.

Value

An interactive spinogram

Examples

require(moonBook)
require(ggplot2)
acs$Dx=factor(acs$Dx,levels=c("Unstable Angina","NSTEMI","STEMI"))
ggSpine(data=acs,aes(x=age,fill=Dx,facet=sex),palette="Reds")
ggSpine(data=acs,aes(x=age,fill=Dx,facet=sex),facetbycol=FALSE,minlabelgroup=0.02)
ggSpine(data=acs,aes(x=age,fill=Dx),palette="Reds")
ggSpine(data=acs,aes(x=smoking,fill=Dx),palette="Reds")
ggSpine(data=acs,aes(x=DM,fill=Dx,facet=sex),palette="Reds")
ggSpine(data=acs,aes(x=Dx,fill=smoking,facet=sex),palette="Reds")
ggSpine(data=acs,aes(x=DM,facet=smoking,fill=Dx),sec.y.axis=TRUE)
ggSpine(data=acs,aes(x=DM,facet=smoking,fill=Dx),facetbycol=FALSE)
ggSpine(mtcars,aes(x=gear,fill=carb),interactive=TRUE)
ggSpine(mtcars,aes(x=gear,fill=carb,facet=am))
ggSpine(data=acs,aes(x=Dx,fill=smoking),position="dodge")
ggSpine(data=acs,aes(x=Dx,fill=smoking),position="stack")

Draw violin plots of a data.frame

Description

Draw violin plots of a data.frame

Usage

ggViolin(
  data,
  mapping = NULL,
  rescale = FALSE,
  horizontal = FALSE,
  alpha = 0.1,
  addBoxplot = TRUE,
  addMean = TRUE,
  use.label = TRUE,
  use.labels = TRUE,
  ...
)

Arguments

data

a data.frame

mapping

Set of aesthetic mappings created by aes or aes_.

rescale

if true, rescale the data.frame

horizontal

if true, horizontal boxplots will be made

alpha

An integer. Default value is 0.1.

addBoxplot

Whether add boxplots on the plot

addMean

Whether add mean point on the plot

use.label

Logical. Whether or not use column label in case of labelled data

use.labels

Logical. Whether or not use value labels in case of labelled data

...

other arguments passed on to geom_boxplot_interactive

Examples

require(ggplot2)
require(ggiraph)
require(reshape2)
ggViolin(iris)
ggViolin(iris,aes(fill=Species),rescale=TRUE)
ggViolin(mtcars,aes(x=c(mpg,cyl,disp,hp,drat),color=am),rescale=TRUE)
ggViolin(mtcars,aes(x=c(mpg,cyl,disp,hp,drat)),rescale=TRUE)

Make a regression equation of a model

Description

Make a regression equation of a model

Usage

makeEq(model, digits = 2)

Arguments

model

A model of class "lm" or"glm" or"loess"

digits

integer indicating the number of decimal places


Make a data.frame of yhat with a model

Description

Make a data.frame of yhat with a model

Usage

model2df(model, x = NULL, n = 100)

Arguments

model

A model of class "lm" or"glm" or"loess"

x

A optional vector of explanatory variable

n

number of observations.


Rescale a vector with which minimum value 0 and maximum value 1

Description

Rescale a vector with which minimum value 0 and maximum value 1

Usage

myscale(x)

Arguments

x

A numeric vector


Rescale a vector with which minimum value 0 and maximum value 1

Description

Rescale a vector with which minimum value 0 and maximum value 1

Usage

myscale2(x, minx = 0, maxx = 1)

Arguments

x

A numeric vector

minx

The minimum value

maxx

The maximum value


find new column name

Description

find new column name

Usage

newColName(df)

Arguments

df

a data.frame


Computing breaks for make a histogram of a continuous variable

Description

Computing breaks for make a histogram of a continuous variable

Usage

num2cut(x)

Arguments

x

A continuous variables

Value

A list contains a factor and a numeric vector


Make numeric column of a data.frame to factor

Description

Make numeric column of a data.frame to factor

Usage

num2factorDf(data, colnames, maxfactorno = 6)

Arguments

data

a data.frame

colnames

Column names to be converted

maxfactorno

maximum unique value of column


Convert p values to character

Description

Convert p values to character

Usage

p2chr(x)

Arguments

x

A vector


Extract colors from a palette

Description

Extract colors from a palette

Usage

palette2colors(name, reverse = FALSE)

Arguments

name

A palette name from the RColorBrewer package

reverse

if true, reverse colors


Paste character vectors separated by colon

Description

Paste character vectors separated by colon

Usage

pastecolon(...)

Arguments

...

Arguments passed on to paste()


Add comma to vectors

Description

Add comma to vectors

Usage

pastecomma(...)

Arguments

...

Argument passed to paste0


Rescale all numeric variables of a data.frame except grouping variable

Description

Rescale all numeric variables of a data.frame except grouping variable

Usage

rescale_df(data, groupvar = NULL)

Arguments

data

A data.frame

groupvar

A column name used as a grouping variable

Value

A rescaled data.frame


Rose sales among 7 groups in a year

Description

A phony dataset representing rose sales

Usage

rose

Format

An object of class data.frame with 84 rows and 3 columns.

Details

@format A data.frame with 84 rows and 3 columns

group

group A to G

Month

Month 1 to 12

value

Rose sales amount


Make a subcolors according to the mainCol

Description

Make a subcolors according to the mainCol

Usage

subcolors(.dta, main, mainCol)

Arguments

.dta

A data.frame

main

A character string of column name used as a main variable

mainCol

A main color


Summarize a continuous variable by groups with mean, sd and SE

Description

Summarize a continuous variable by groups with mean, sd and SE

Usage

summarySE(
  data = NULL,
  measurevar,
  groupvars = NULL,
  conf.interval = 0.95,
  na.rm = TRUE,
  .drop = TRUE
)

Arguments

data

A data.frame

measurevar

A name of variable to measure a mean and sd

groupvars

Name(s) of variable used as a grouping variables

conf.interval

confidence interval

na.rm

A logical value indicating whether or not remove NA values

.drop

should combinations of variables that do not appear in the input data be preserved (FALSE) or dropped (TRUE, default)

Value

A data.frame summarized a continuous variable by groups with mean, sd and SE


Taco ratings by age group

Description

Taco ratings by ShellType, AgeGroup and Filling source: Communicating experiment results with R

Usage

taco

Format

An object of class data.frame with 136 rows and 4 columns.

Details

@format A data.frame with 136 rows and 4 columns

ShellType

Hard or Soft

Fillings

Fillings of taco

AgeGroup

AgeGroup One of the c("<13","13-20","21-39","40+",)

Rating

A numeric. Rating of taco


Clean theme for PieDonut plot

Description

Clean theme for PieDonut plot

Usage

theme_clean(base_size = 12)

Arguments

base_size

An integer, default 12.


Clean theme for ggCor

Description

Clean theme for ggCor

Usage

theme_clean2(base_size = 12, xangle = 45, yangle = 0)

Arguments

base_size

base font size

xangle

x-axis text angle

yangle

y-axis text angle


Unselect numeric column of a data.frame

Description

Unselect numeric column of a data.frame

Usage

unselectNumeric(data, colnames, maxfactorno = 6)

Arguments

data

a data.frame

colnames

Column names to be converted

maxfactorno

maximum unique value of column