songsim: Calculating and Visualizing a "Song Similarity" matrix

Description Usage Arguments Details Value Note References Examples

View source: R/songsim.R

Description

This function will calculate the "song similarity" of a given song's lyrics stored in a text file. A cell (i, j) is filled if word i in a song's lyrics is the same as word j. This method was first suggested by Colin Morris (see URLs)

Usage

1
2
3
songsim(path = NULL, colorfulMode = FALSE, singleColor = "black",
  interactiveMode = FALSE, mainTitle = "", plotOptions = NULL,
  heatmaplyOptions = NULL, plotMatrix = TRUE)

Arguments

path

Path to a txt file holding the song's lyrics

colorfulMode

A boolean indicating whether to plot the matrix in color (see @details), defaults to FALSE

singleColor

What is the color to use for a full matrix cell (see @details)

interactiveMode

A boolean indicating whether to plot the matrix in interactive mode using the 'heatmaply' package (see @details), defaults to FALSE

mainTitle

plot's main title, defaults to an empty string

plotOptions

Additional parameters for the base 'plot' function (non-interactive mode)

heatmaplyOptions

Additional parameters for the 'heatmaply' function (non-interactive mode)

plotMatrix

A boolean indicating whether to plot the matrix, defaults to TRUE

Details

A cell (i, j) in a songsim square matrix is filled if word i in a song's lyrics is the same as word j. This simple rule would create fascintaing visualizations of songs lyrics as shown in the links below.

If colorfulMode is set to TRUE, each word which appears more than once will be colored with its own color (currently only available with interactiveMode set to FALSE).

If interactiveMode is set to TRUE and the user has the heatmaply package installed - the songsim matrix will be plotted using an interactive heatmap.

The singleColor corresponds to the color a full cell is colored with. If in colorfulMode it would be the color of words which appear only once.

Value

a list containing:

songMat

a song similarity square matrix of dimensions no. of words x no. of words, containing all 0 and 1

repetitiveness

an experimental measure of repetitiveness which is the mean of the upper triangular part of song matrix

Note

This function was only tested on typical pop songs or poems, it was not tested on large pieces of texts

References

A blog post describing the package with more examples: http://giorasimchoni.com/2017/08/08/2017-08-08-lambada-the-mocap-package/

A blog post by Colin Morris describing interesting "songsims": https://colinmorris.github.io/blog/weird-pop-songs

An interactive React (JS) demo by Colin Morris with more examples: https://colinmorris.github.io/SongSim/

Examples

1
2
path <- system.file("extdata", "formation.txt", package = "songsim")
songsim(path)

gsimchoni/songsim documentation built on May 28, 2019, 8:54 p.m.