ggplot(salary_2013, aes(x=reorder(行業,-平均工時), y=平均工時)) + # reorder x
+ geom_bar(stat='identity', alpha=.5) + # set transparency
+ labs(x='行業別', y='平均月(加班)工時', title='正常工時(虛)與加班工時(實)') +
+ theme(# for OS X (XQuartz device) to show Chinese characters
+ text=element_text(family='Heiti TC Light'),
+ # rotate angle of x ticks
+ axis.text.x=element_text(angle=90, hjust=1, vjust=.5),
+ # change size of title
+ plot.title=element_text(size=26)) +
+
+ # argument data is skipped in the second call to geom_bar
+ geom_bar(aes(x=行業, y=as.numeric(as.character(加班工時))), stat='identity') +
+
+ # add arbitrary text (refer to the bonus section of this lecture)
+ annotate('text', label='囧', color='red', family='Heiti TC Light', size=10, vjust=-.25,
+ x=which(levels(reorder(salary_2013$行業,-salary_2013$平均工時)) == '製造業'),
+ y=as.numeric(as.character(salary_2013[salary_2013$行業=='製造業', '加班工時'])))
Error in tapply(X = X, INDEX = x, FUN = FUN, ...) :
arguments must have same length