当在GGPLOT2中使用Labeller函数时,只有在查找表中找到原始值时才能应用它?在下面的示例中,我正在使用
as_labeller()
重命名一些汽车类。查找表中没有的任何内容都默认为“ na”。我希望它保留其原始名称。这可能吗?
library(ggplot2)
#base plot without any labels
p <- ggplot(mpg, aes(displ, hwy)) + geom_point()
p + facet_wrap(~class)
#add fancy labels - but only for some classes
fancy_labs <- as_labeller(c('2seater' = 'Seats Two!', 'compact' = "Small Family Car"))
p + facet_wrap(~class, labeller = fancy_labs)
我想要第二个情节的标题来读:“座位两个!” “小型家庭汽车”“中型”“小型货车”(等)