I am plotting results from Redundancy analysis using ggplot and I got a warning:
Removed 2 rows containing missing values (`geom_segment()`).
This warning lead to the missing two arrows in the figure (for variable "Family labor" and "Hired labor").
However, the data used for plot the segment do not include missing values.
Please see the below code for plot and the data for geom_segment.
ggplot() +
geom_point(data = sp2,aes(RDA1,RDA2),fill="dodgerblue1",shape=22,size=4.5)+
scale_fill_brewer(palette = 'Set2')+
geom_text_repel(data = sp,aes(RDA1,RDA2,label=sp2$Group),color="black",size=6)+
geom_segment(data = yz,aes(x = 0, y = 0, xend = RDA1, yend = RDA2,shape=grp.yz$Group,fill=grp.yz$Group),
arrow = arrow(angle=22.5,length = unit(0.35,"cm"),
type = "closed"),linetype=1, size=0.7,colour = "gray70")+
geom_point(data = yz,aes(RDA1,RDA2,fill=grp.yz$Group),size=4.5,shape=21)+
#scale_shape_manual(values = c(22:23))+
geom_text_repel(data = yz2,aes(RDA1,RDA2,label=yz2$label),size=6)+
# scale_fill_brewer(palette = 'Set2')+
labs(x=paste("RDA 1 (", format(100 *ii$cont[[1]][2,1], digits=3), "%)", sep=""),
y=paste("RDA 2 (", format(100 *ii$cont[[1]][2,2], digits=3), "%)", sep=""))+
geom_hline(yintercept=0,linetype=3,size=1,color="gray50") +
geom_vline(xintercept=0,linetype=3,size=1,color="gray50")+
guides(shape=guide_legend(title=NULL,color="black"),
fill=guide_legend(title=NULL))+
theme_bw()+theme(panel.grid=element_blank())+
#theme(legend.title = element_blank()) +
theme(legend.position = "none") +
theme(legend.text = element_text(colour="black", size = 13)) +
#theme(legend.background = element_rect(fill="white", size=0.2, linetype="solid", colour ="black")) +
theme(axis.title.x = element_text(colour="black",size=14),
axis.text.x = element_text(colour="black",size=14)) +
theme(axis.title.y = element_text(colour="black",size=14),
axis.text.y = element_text(colour="black",size=14))
Data for geom_segment:
RDA1 RDA2 id
COVID_experience_yes 0.079791785 0.14111628 1
COVID_lockdown 0.144604188 -0.27902139 2
Family_labour -0.042481422 -0.21235206 3
Hired_labour 0.317842345 0.18081804 4
Information_access 0.217181899 -0.16861407 5
Group_membership -0.021734340 -0.07815768 6
Shortest_distance 0.100966592 -0.22021657 7
Precipitation -0.115402219 0.22859724 8
Temperature -0.005440390 -0.16467817 9
Elevation 0.005769102 -0.01466336 10
Slope -0.054949492 -0.02525952 11
Production_area_ha 0.903160453 0.12789322 12
Borrow_money 0.405894836 0.02389362 13
BMP_adoption 0.336062487 0.04447044 14
Fish_selling_price 0.015581173 0.03274025 15
Distance_nearest_market 0.404554579 -0.75961346 16
Thank you very much in advance for your help.