Reputation: 2539
It is possible to change the column label of factor levels without having to change the values in the data.frame
for example in the following graph can I change the label of Female and Male to F and M respectively without having to change the df?
library(GGally)
data(tips, package = "reshape")
pm <- ggpairs(tips, 1:3, columnLabels = c("Total Bill", "Tip", "Sex"))
pm
Upvotes: 1
Views: 2440
Reputation: 4818
After
pm <- ggpairs(tips, 1:3, columnLabels = c("Total Bill", "Tip", "Sex"))
do this
levels(pm$data$sex)[levels(pm$data$sex) == "Male"] = "M"
levels(pm$data$sex)[levels(pm$data$sex) == "Female"] = "F"
You'll get this plot:
It won't change anything in tips
dataset:
head(tips)
total_bill tip sex smoker day time size
1 16.99 1.01 Female No Sun Dinner 2
2 10.34 1.66 Male No Sun Dinner 3
3 21.01 3.50 Male No Sun Dinner 3
4 23.68 3.31 Male No Sun Dinner 2
5 24.59 3.61 Female No Sun Dinner 4
6 25.29 4.71 Male No Sun Dinner 4
Upvotes: 2