First of all, thanks a lot for this package, it is a lot of fun to work with R + music!
When turning a dataframe into a melody I noticed that there is an issue with the NAs.
This is an example which recreates the error:
library(gm)
df <- data.frame(num = 40:50)
df[df == 45] <- NA
m <- Music() + Meter(4, 4) +
Line(pitches = as.list(df$num),
durations = as.list(rep("quarter", nrow(df))))
I get this error message:
Each item of pitches
must be a single logical NA, or be a character or numeric vector containing pitch notations and MIDI note numbers.
pitches[[6]][1]
is NA_integer_.
However, when I run through the list and replace all the NA_integer_ with NA, it works - so it has something to do with the different types of NA_integer_, NA_character_ etc. and the normal NA.
m <- Music() + Meter(4, 4) +
Line(pitches = lapply(as.list(df$num),
function(x) if(is.na(x)) NA else x),
durations = as.list(rep("quarter", nrow(df))))
This probably does not have a high priority, but in case that it is easy to fix, maybe it would be great to interpret NA_integer_ also as pauses.
Thanks again, awesome package!