如何比较两个列表

时间:2019-10-28 01:52:53

标签: r ggplot2

我正在尝试在x轴上加粗一些名称。例如,

fruits = c("apple", "orange", "watermelons")
juice_content = c(10, 1, 1000)
weight = c(5, 2, 2000)
df = data.frame(fruits, juice_content, weight)
df = gather(df, compare, measure, juice_content:weight, factor_key=TRUE)
plot = ggplot(df, aes(fruits, measure, fill = compare)) + 
         geom_bar(stat = "identity", position = position_dodge())

我希望标签orange在x轴上为粗体。

编辑。借助注释的帮助,我能够将x轴加粗。但是,我无法比较两个列表。

这里有 fruits = c("apple", "orange", "watermelons")

让我们说这个列表已经变长了:fruits = c("apple", "orange", "watermelons","pears","banana","mango"),而水果列表又变短了:short_fruit=c("orange","apple","mango")

我如何比较它们?

我尝试了vec_fontface <- ifelse(fruit == short_fruit,"bold","plain") 但这似乎不起作用。

0 个答案:

没有答案