## Data

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

## Determine traits with missing values

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

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(dfr, center = TRUE, scale = TRUE)
summary(princip)
print(princip$x)
factoextra::fviz_pca(princip, repel = TRUE,
                     title = "Biplot of genotypes and attributes")


CIP-RIU/hidap documentation built on April 30, 2021, 9:21 p.m.