Reputation: 7469
I am trying to change the legend size of my ggplot2 plot and am running into an error about a missing function:
> xy <- data.frame(x=1:10, y=10:1, type = rep(LETTERS[1:2], each=5))
> plot <- ggplot(data = xy) + geom_point(aes(x = x, y = y, color=type))
> plot + theme(legend.key.width = unit(5, "cm"))
Error in theme(legend.key.width = unit(5, "cm")) :
could not find function "unit"
Am I missing something or is this a bug? I am running most recent versions:
> getRversion()
[1] ‘3.2.0’
> packageVersion('ggplot2')
[1] ‘1.0.1’
Upvotes: 1
Views: 2435
Reputation: 7832
unit
is a function of the grid
package. Just load library(grid)
, and it should work.
Edit: sorry, didn't see the comment, which already answered this question...
Upvotes: 3