-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NA and NA_integer_ problem #12
Comments
@richardvogg I am happy to know you like this package! The NA issue has already been fixed, you may try the latest version from CRAN or Github. gm now accepts NA of any type. You can now do something like this: as.list(c("C4", NA, "D4"))
as.list(c(60, 61, NA, 90)) |
Thank you for the quick reply, I will install the latest version. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!
The text was updated successfully, but these errors were encountered: