Reputation: 55
I'm looking to figure out how to change the x-labels that show the default M and F variables from the data frame to become "Male" and "Female" instead. I tried looking online, but I still couldn't seem to find the best approach for this.
This is my code
# Create a visualization between males and female subjects
ggplot(data=subjectID,aes(x=Sex,fill=Sex))+geom_bar(col="black") +
xlab("Sex") + ylab("Count") + ggtitle("Count Between Males and Females")
This gets me to generate a graph that looks like this below. Any help on changing this would be appreciated thank you!
Upvotes: 0
Views: 940
Reputation: 51
The issue here is not with the graph label names. The M and F are the two unique values in your column Sex of subjectID
data frame, which are being plotted. Instead of changing the x and y labels, you need to replace the M and F to Male and Female respectively in your Sex column of subjectID
dataframe.
This code might help you fix the issue.
subjectID[subjectID=="M"]<-'Male'
subjectID[subjectID=="F"]<-'Female'
Run these two lines before plotting the graph
Upvotes: 1