我正在尝试为 ggplot2 图重新标记 x 和 y 方面。
我发现了多种编写函数来重新标记一个方面的方法,但不是两者兼而有之。
head(nh2)
RatioIncomePoverty Ethnicity Education mean.bmi
1 0 1 1 26.18333
2 0 1 1 30.88000
3 0 1 2 32.03000
4 0 1 4 34.45000
5 0 2 1 26.33000
6 0 2 2 23.44000
b2 <- qplot(RatioIncomePoverty, mean.bmi, data=nh2, facets=Education~Ethnicity)
b2 = b2 + labs(list(title="Average BMI and Ratio of Family Income to Poverty Threshold among US Ethnic groups", x = "Ratio of Family Income to Poverty Threshold", y = "Average BMI"))
b2
目前,教育和种族都有 1-5 的值,我想将它们重命名为它们在调查中对应的值。
Education:
1 = "<9th"
2 = "9th-11th"
3 = "GED"
4 = "Some/AA"
5 = "Grad"
Ethnicity:
1 = "Mex/Amer"
2 = "OtherHisp"
3 = "White"
4 = "Black"
5 = "Other/Multi"