How do I plot a pch=4 value on the coordinates of this map?

xcoord and ycoord are just a bunch of random numbers starting from 1-100

plot(xcoord,ycoord,pch=15, col="grey", 
     main="Map of Africa",xlim=c(27,46),
     xlab="Latitude",ylab="Longtitude")

When the above function is run, the output is a condensed scatter plot that resembles a grey map of a region in africa. Please note 46891 are the total number of rows in the dataframe

pvals are pvalues

pvals <- c(rep(0,49681))
slopes <- c(rep(0,49681))

If I run the below code, I receive areas of marked in green red and rest as tan.(Image attached)

for(i in 1:49681){

  if(pvals[i] < 0.01 & slopes[i]>0)points(xcoord[i],ycoord[i],pch=15,col="green",cex=0.4)
  if(pvals[i] < 0.01 & slopes[i]<0)points(xcoord[i],ycoord[i],pch=15,col="red",cex=0.4)
  if(pvals[i] >= 0.01)points(xcoord[i],ycoord[i],pch=15,col="tan",cex=0.4)
}

However,I specifically want to mark coordinates within this colored map
I tried to do this with the below code but it just plots the same image of a colored map without an X. The X is symbol pch=4

for(i in 1:49681){
  if(pvals[i] < 0.01 & slopes[i]>0)points(xcoord[i],ycoord[i],pch=15,col="green",cex=0.4)
  if(pvals[i] < 0.01 & slopes[i]<0)points(xcoord[i],ycoord[i],pch=15,col="red",cex=0.4)
  if(pvals[i] >= 0.01)points(xcoord[i],ycoord[i],pch=15,col="tan",cex=0.4)
  if(pvals[i] == 0.003851973 & slopes[i![map|665x362](upload://ehGEiUGZoLm1BLV6oalvfJ5dQSc.jpeg) ] == 0.1493456)points(xcoord[i],ycoord[i],pch=4,col="black",cex=15)
  if(pvals[i] == 0.3921581 & slopes[i] == -0.04883013)points(xcoord[i],ycoord[i],pch=4,col="black",cex=15)
}

What should I alter in the final code?

Hi @joelt92, I just wanted to let you know that it’s discouraged in this form to @name mention another user in a post if they are not already participating in the thread. See this FAQ for more details:

@mfherman I was not aware of this policy. Thanks for the headsup.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.