I have following dataset:
CATEGORY ID Mode_A Mode_B Mean_A Mean_A
A 1 4 2 2.1 3.4
A 2 1 2 4.2 2.7
B 3 1 1 3.2 4.1
B 4 4 2 1.5 1.2
I have created following plot:
ggplot(data = tabla_moda)
geom_point(mapping = aes(x = Media_Impacto, y = Media_Esfuerzo, color = Moda_Impacto, size = Moda_Esfuerzo)
)
I am trying to add to all the points in the graph ID rowname from my DATASET
I have tried:
ggplot(data = tabla_moda)
geom_point(mapping = aes(x = Media_Impacto, y = Media_Esfuerzo, color = Moda_Impacto, size = Moda_Esfuerzo)
ggrepel::geom_text_repel(label = ID, nudge_x=0.45, nudge_y=0.1,check_overlap=T)
)
ggplot(data = tabla_moda, mapping = aes(x = Media_Impacto, y = Media_Esfuerzo, color = Moda_Impacto, size = Moda_Esfuerzo, label = rownames(ID)))
geom_point()
geom_text(label = ID, nudge_x=0.45, nudge_y=0.1,check_overlap=T)
But I am always getting ID, same error:
ID object not found
Thanks in advance for your help
CodePudding user response:
It's because the ID is a variable of your dataset, so you should include it always as an aesthetic, I think this should work:
ggplot(data = tabla_moda, mapping = aes(x = Media_Impacto, y = Media_Esfuerzo, color = Moda_Impacto, size = Moda_Esfuerzo))
geom_point()
geom_text(aes(label = ID), nudge_x=0.45, nudge_y=0.1,check_overlap=T)
