-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
When using geom_text() if the angle parameter is set using a variable whose value can be NA then geom_text() throws an error (Error in validDetails.text(x) : invalid 'rot' value) when it encounters the NA value. Desired behavior would be to handle this gracefully and simply NOT plot the NA value (as would happen with other aesthetics).
library(ggplot2)
df <- data.frame(x=seq(1,10,1), y=seq(1,10,1), angle=c(seq(0,80,10),NA))
# this works:
ggplot(df[1:9,], aes(x=x, y=y)) + geom_text(label="-", aes(angle=angle))
# this breaks:
ggplot(df, aes(x=x, y=y)) + geom_text(label="-", aes(angle=angle))
# with error:
# Error in validDetails.text(x) : invalid 'rot' value
# also a confusing error because the user did not pass a 'rot' parameter.
# that 'rot' == 'rotation' == 'angle' may not be entirely clear to users.
