Stack Exchange
How to adjust labels of loadings in ggplot?
I can't get the labels to go at the end of the arrows instead of the base:

here is the exact code I used:
ggplot <- ggplot(data=sep_total_raw_data, aes(x=pc1t, y=pc2t))+geom_point(alpha=0.8, size=1,aes(colour=Data_Type, shape=Data_Type))+xlab("PC1 (53.83%)")+ylab("PC2 (26.3%)")+guides(colour=guide_legend(title="Data_Type"))+geom_mark_hull(concavity=5, expand=0, radius=0, aes(fill=Data_Type))+theme(panel.grid = element_blank(), panel.border = element_rect(fill = "transparent"))+geom_text(aes(label=Code, fontface="bold", colour=Data_Type))

ggplot + geom_segment(data = PCA_loadings, aes(x=0, y=0, xend=PC1*4.6, yend=PC2*4.6), arrow = arrow(length = unit(0.03, "npc")), alpha=1)+ geom_text(data=PCA_loadings, mapping = aes(x=PC1, y=PC2, label=rownames(PCA_loadings)), hjust=1, vjust=-0.2)

Here is the reproducible code:
ggplot <- ggplot(data=iris, aes(x=Petal.Length, y=Petal.Width))+geom_point(alpha=0.8, size=1,aes(colour=Species, shape=Species))+xlab("Petal Length")+ylab("Petal Width")+guides(colour=guide_legend(title="Species"))+geom_mark_hull(concavity=5, expand=0, radius=0, aes(fill=Species))+theme(panel.grid = element_blank(), panel.border = element_rect(fill = "transparent"))+geom_text(aes(label=Species, fontface="bold", colour=Species))

Can anyone tell me how to get the loadings labels to sit at the end of the arrows?

The reproducible example using the iris data set doesn't have any arrows or text included. To put the text at the end of the arrows, the x and y values for the text should match the xend and yend values for the arrows. You have e.g. x = PC1 for text but xend = PC1 * 4.6 for the arrows - they should be the same. PS it's good practice to avoid defining variables with the same name as functions you are using.

@nrennie that worked, thank you so much!
