Hey everyone,
I'm attempting to produce a faceted grid of scatter plots for species presence and absence (indicated by a 1 for present and a 0 for absent) against coordinates. So far I've been able to produce a faceted scatter plots for 70 sites and 12 species however they all appear identical.
I wonder if I am missing something to make any 0 instances invisible / excluded from the figures? What I would like to see is a scatter plot for each species showing a point for where that species was present.
The script below replicates the issue for 5 sites and still gives the same issue of identical scatter plots.
Thanks for any help in advance!
#creating example dataframe
df <- data.frame(Site = c("S01", "S02", "S03", "S04", "S05"),
Easting = c(634571, 635625, 635985, 636208, 638082),
Northing = c(6306325, 6306939, 6304130,6301157, 6299408),
Species1 = c(1,1,0,0,1),
Species2 = c(0,0,1,0,0),
Species3 = c(1,0,1,0,1),
Species4 = c(0,0,1,1,1))
#pivoting dataframe for ggplot
df.piv <- pivot_longer(df, cols = c(4:7), names_to = "Species", values_to = "presence/absence")
#plotting scatterplots
ggplot(df.piv) +
geom_point(aes(x=Easting,y=Northing)) +
facet_wrap(~Species) +
theme_bw() +
ylab("Northing")+ xlab("Easting")