## Data

traits <- params$traits
data <- params$data
rownames(data) <- data[, "INSTN"]
data <- data[, traits]

## Determine traits with missing values

lit <- map(data, anyNA) %>% unlist()
lgc_lit <- lit %>% as.vector()
lgc_val <- any(lgc_lit == TRUE)
names_trait <- names(lit[lgc_lit])
msg <- paste(names_trait, collapse = ", ") %>% paste("The next traits have missing values: ",., sep = "")

r if(lgc_val) {"There are missing values in some traits. For this reason, we could not perform a principal components analysis"}

cat(msg)

r if(!lgc_val) { "A principal components analysis is shown to see the associations among the genotypes and some attributes."}

princip <- prcomp(data, center = T, scale = T)
summary(princip)
print(princip$x)
factoextra::fviz_pca(princip, repel = T,
                     title = "Biplot of genotypes and attributes")


AGROFIMS/hagrofims documentation built on May 6, 2020, 7:43 p.m.