animSolar {corrViz}R Documentation

animSolar

Description

This function creates an animated solar system plot of correlations between variables in a dataset.

Usage

animSolar(
  mat,
  sun = NULL,
  export = FALSE,
  num_frames = 100,
  path = NULL,
  gif_name = "solar_system.gif",
  fps = 60
)

Arguments

mat

A square correlation matrix to visualise.

sun

A character string specifying the column name in the dataset to be treated as the 'sun' in the solar system plot.

export

A logical value specifying whether to export the animation as a GIF file, default is FALSE.

num_frames

An integer specifying the number of frames in the animation, default is 100.

path

A character string specifying the directory path where the GIF file will be saved, default is NULL.

gif_name

A character string specifying the name of the GIF file. Must be in the format "myFile.gif"

fps

An integer specifying the frames per second for the animation. Default is 60 and is only used when exporting a gif via export = TRUE.

Details

In a solar system correlation plot, the dependent variable of interest is positioned at the center, represented as the sun. The explanatory variables are depicted as planets orbiting around the sun, with their distance from the sun corresponding to the absolute value of their correlation with the dependent variable. Therefore, the greater the distance of a planet from the sun, the weaker the correlation between the explanatory variable and the dependent variable.

The num_frames argument is used to select the number of frames. Setting this to a low value will produce the plot quicker, however having a low number of frames will result in the "planets" jumping as the frames transition. Additionally, a low values of num_frames will affect the orbit of the animation when setting export = FALSE. This differs from the fps argument which sets the number of frames to play per second for use when exporting a gif.

Value

An animated solar system plot displaying correlations.

Examples

cm <- cor(mtcars)

animSolar(mat = cm,
          sun = 'mpg',
          export = FALSE,
          num_frames = 25)


[Package corrViz version 0.1.0 Index]