I am using this to make a CCA triplot,
data = structure(list(Location = c("Xiamen Bay", "Xiamen Bay", "Xiamen Bay",
"Xiamen Bay", "Xiamen Bay", "Xiamen Bay", "Xiamen Bay", "Xiamen Bay",
"Xiamen Bay", "Xiamen Bay", "Xiamen Bay", "Xiamen Bay", "Jiulong River",
"Jiulong River", "Jiulong River", "Jiulong River", "Jiulong River",
"Jiulong River", "Jiulong River", "Jiulong River", "Jiulong River",
"Jiulong River"), Station = c("X1", "X2", "X3", "X4", "X5", "X6",
"X7", "X8", "X9", "X11", "X12", "X13", "A3", "A4", "A5", "A6",
"A7", "A8", "A9", "A9-1", "JY-1", "JY-2"), PP = c(15.47, 0, 24.8,
49.6, 51.2, 0, 44.27, 0, 36.8, 56.8, 30.4, 0, 14.6, 13.6, 47.4,
30.8, 15.4, 36.8, 55.8, 0, 0, 29.6), PP.PE = c(30.93, 0, 36.4,
16.53, 51.2, 34.67, 66.4, 41.6, 36.8, 0, 30.4, 69.33, 0, 0, 0,
15.4, 0, 0, 37.2, 0, 0, 0), PE = c(15.47, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 30.8, 15.4, 36.8, 0, 0, 0, 59.2), PES = c(30.93,
40.53, 37.47, 16.53, 0, 52, 0, 62.4, 36.8, 0, 15.2, 27.73, 0,
27.2, 47.4, 0, 30.8, 18.4, 0, 50.4, 44.4, 29.6), PET = c(0, 20.27,
12.14, 0, 0, 0, 44.27, 0, 0, 0, 15.2, 0, 29.2, 13.6, 0, 0, 46.2,
18.4, 18.6, 0, 14.8, 0), Rayon = c(61.87, 40.53, 24.8, 49.6,
51.2, 69.33, 44.27, 0, 18.4, 113.6, 30.4, 41.6, 29.2, 54.4, 63.2,
77, 30.8, 36.8, 37.2, 84, 59.2, 14.8), Acrylic = c(0, 60.8, 49.6,
16.53, 17.07, 17.33, 0, 41.6, 55.2, 0, 15.2, 0, 29.2, 0, 0, 0,
15.4, 36.8, 18.6, 16.8, 14.8, 14.8), Other = c(0, 40.54, 62.8,
16.53, 0, 0, 22.13, 62.4, 0, 18.93, 15.2, 0, 43.8, 27.2, 0, 0,
0, 0, 18.6, 16.8, 14.8, 0)), row.names = c(NA, 22L), class = "data.frame")
the code I was using was
library(CCA)
data_set1 <- data[, c("Location", "Station")]
data_numeric <- data[, -(1:2)]
cca_result <- cc(data_set1, data_numeric)
but after i run this code i the error was
Error in cov(X, Y, use = "pairwise") :
is.numeric(x) || is.logical(x) is not TRUE
In addition: Warning message:
In var(X, na.rm = TRUE, use = "pairwise") : NAs introduced by coercion
but if check my data you’ll not see any NA’s in my data. I also convert data_set1 in to factor
like
data$Location <- as.factor(data$Location)
data$Station <- as.factor(data$Station)
and but still the same error. what should i do, I want to make CCA triplot, where arrows will be the variables like PP
, PE
……, and the lebel of the scatter plot will be Station
grouped color of the scatter plot will based on Location