GGGuitar

Casimir Saternos

2016-11-29

This vignettes is a brief introduction to the ggguitar package. The graphics are based on ggplot2 and processing on the tidyverse in general.

library(ggguitar)
library(tibble)
library(ggplot2)

# Ignoring warnings
options( warn = -1 )

Special thanks to Dr. Hadley Wickham and the crew at RStudio whose work does all of the heavy lifting.

Examples of Tablature

A chord in ggguitar is represented as a vector containing 6 elements. Each element represents a string. A numeric value represents the fret where a finger is placed. Zero represents an open string, NA represents a string not played (either skipped or muted).

A G Major chord can be represented using the following vector.

G_M <- c(3, 2, 0, 0, 0, 3)

The ggguitar method can be used to create the tablature for this chord. The numbers in the vector represent fret positions with zeros indicating open strings. By default the x and y axis are labeled as Strings and Frets along with associated numbers.

ggguitar::tablature('G Major', G_M)

If a given string is not to be played, an NA is used rather than an integer representing the fret number.

B_M <- c(NA, 2, 4, 4, 4, 2)
ggguitar::tablature('B Major', B_M)

Both open strings and ignored/muted strings can be included in the same chord.

C_M <- c(NA, 3, 2, 0, 1, 0)
ggguitar::tablature('C Major', C_M)

Chords need not be restricted to first position. In the next example, a bar chord further up the neck is represented.

C_M_bar <- c(8, 10, 10, 9, 8, 8)
ggguitar::tablature('C Major (bar)', C_M_bar)

Charts can be assigned to variables and then displayed together using grid.arrange.

D_M <- c(NA, NA, 0, 2, 3, 2)
F_M7 <- c(NA, NA, 3, 2, 1, 0)
e_m <- c(0, 2, 2, 0, 0, 0)
a_m <- c(NA, 0, 2, 2, 1, 0)
b_m <- c(NA, 2, 4, 4, 3, 2)

G_Major <- tablature('G Major', G_M)
C_Major <- tablature('C Major', C_M, TRUE, FALSE)
D_Major <- tablature('D Major', D_M, FALSE, FALSE)
e_minor <- tablature('e minor', e_m)
a_minor <- tablature('a minor', a_m, TRUE, FALSE)
b_minor <- tablature('b minor', b_m)

gridExtra::grid.arrange(G_Major, C_Major, D_Major,
              a_minor, b_minor, e_minor,
              ncol = 3)

sessionInfo()
## R version 3.3.2 (2016-10-31)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: OS X El Capitan 10.11.6
## 
## locale:
## [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] ggplot2_2.1.0  tibble_1.2     ggguitar_0.1.0
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.12.7      digest_0.6.10    assertthat_0.1   plyr_1.8.4      
##  [5] grid_3.3.2       gtable_0.2.0     formatR_1.4      magrittr_1.5    
##  [9] scales_0.4.0     evaluate_0.9     stringi_1.1.2    lazyeval_0.2.0  
## [13] rmarkdown_1.0    tools_3.3.2      stringr_1.1.0    munsell_0.4.3   
## [17] yaml_2.1.13      colorspace_1.2-6 htmltools_0.3.5  knitr_1.14      
## [21] gridExtra_2.2.1