Colored sites in RDA

Hello,
I would like to perform an rda by having my sampleID sites colored according to their cluster membership (Clust).
I made this code but unable to do it

Clust <- tibble::tribble(
             ~SampleID, ~cluster, 
                  "1A",       1
                  "1C",       1
                  "1D",       1     
                  "1E",       2
                  "1F",       3
                  "1G",       3
                  "1H",       2
                  "2A",       2       
                  "2B",       1
                  "2C",       1 
                  "2D",       3
                  "2E",       3   
                  "2F",       2    
                  "2H",       1
)
Env <-tibble::tribble(
            ~SampleID, ~Dissolved.oxygen,   ~pH,   ~WT, ~Turbidity,   ~ORP, ~Ammonium, ~Nitrates,      ~BGA, ~Chlrophyll,   ~CE,   ~AT, ~Evaporation, ~Precipitation,
                 "1A",   4.24,  9.94, 24.48,       87.3,     97,      4.46,       3.6,    279133,        36.6, 1.074, 13.95,         4.34,           2.55,
                 "1C",   2.85,  9.98, 24.01,       98.8,  102.9,      4.37,      3.57,    265304,          40, 1.081, 13.95,         4.34,           2.55,
                 "1D",   3.81,  9.07, 26.67,       24.9,     94,       5.6,      3.53,     11603,          44, 1.147, 17.11,          5.8,           4.54,
                 "1E",   2.64,  8.99, 24.01,       43.1,   63.9,      3.38,      2.55,    218471,          35, 1.156, 17.11,          5.8,           4.54,
                 "1F",   4.61,  8.93,  23.5,       49.1,   64.7,      3.21,      2.28,    226658,        32.8, 1.157, 17.11,          5.8,           4.54,
                 "1G",   5.74,  9.24, 24.46,       68.6,   40.3,      1.93,      0.71,    267389,          44, 1.072,  17.9,         6.86,           6.88,
                 "1H",   3.69,  9.32, 24.65,       69.8,   48.1,      2.21,       1.2,    267144,        44.8, 1.152,  17.9,         6.86,           6.88,
                 "2A",   4.24,  9.94, 24.48,       87.3,     97,      4.46,       3.6,    279133,        36.6, 1.074, 13.95,         4.34,           2.55,
                 "2B",   2.66,    10, 24.92,        113,  111.9,      4.75,      3.21,    270193,        39.8, 1.081, 13.95,         4.34,           2.55,
                 "2C",   2.85,  9.98, 24.01,       98.8,  102.9,      4.37,      3.57,    265304,          40, 1.081, 13.95,         4.34,           2.55,
                 "2D",   3.81,  9.07, 26.67,       24.9,     94,       5.6,      3.53,     11603,          44, 1.147, 17.11,          5.8,           4.54,
                 "2E",   2.64,  8.99, 24.01,       43.1,   63.9,      3.38,      2.55,    218471,          35, 1.156, 17.11,          5.8,           4.54,
                 "2F",   4.61,  8.93,  23.5,       49.1,   64.7,      3.21,      2.28,    226658,        32.8, 1.157, 17.11,          5.8,           4.54,
                 "2H",   3.69,  9.32, 24.65,       69.8,   48.1,      2.21,       1.2,    267144,        44.8, 1.152,  17.9,         6.86,           6.88
)

Spe <-tibble::tribble( 
~SampleID, ~Cyanobacteriaceae, ~Microcystaceae, ~Nostocaceae,
                  "1A",        1.342953283,               0,            0,
                  "1C",        1.966304234,               0,            0,
                  "1D",                  0,               0,   1.80374141,
                  "1E",        1.492119211,               0,  1.492119211,
                  "1F",        0.597623166,               0,            0,
                  "1G",        1.319782597,               0,            0,
                  "1H",        0.859080227,      6.52598632,  0.859080227,
                  "2A",                  0,               0,  1.907218755,
                  "2B",        0.793958833,               0,            0,
                  "2C",                  0,     2.023336602,            0,
                  "2D",        0.859080227,               0,            0,
                  "2E",                  0,               0,  2.333056481,
                  "2F",                  0,     4.129704923,            0,
                  "2H",                  0,               0,  2.333056481,
clust$cluster <- as.character(clust$cluster)
levels(clust$cluster) <- c("Area1","Area2","Area3"))
bg <- c("blue","green","red") 
eco <- clust$cluster

rda_object <- rda(Spe[,-1], Env, scale=TRUE)
# axes 1 & 2
plot(spe.rda, type="n", scaling=1)
text(spe.rda, display="species", pch=20, cex=1, col="red", scaling=1)          
points(spe.rda, display="sites", pch=20, cex=1.3, scaling = 1, bg=bg[eco]) 
text(spe.rda, scaling=1, display="bp", col="darkorange", cex=1)

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.