pop_data <- gl@pop
snp_data <- gl@SNPs #you_could_transform_gl_to_dataset_in_this_step
unique_pops <- unique(pop_data)
population_matrices <- list()
for (pop in unique_pops) {
population_matrices[[pop]] <- snp_data[pop_data == pop, ]
}
na_percentages <- list()
for (pop in names(population_matrices)) {
pop_matrix <- population_matrices[[pop]]
na_percentage <- sum(is.na(pop_matrix)) / (nrow(pop_matrix) * ncol(pop_matrix)) * 100
na_percentages[[pop]] <- na_percentage
}
na_percentages
pop_data <- gl@pop
snp_data <- gl@SNPs #you_could_transform_gl_to_dataset_in_this_step
unique_pops <- unique(pop_data)
population_matrices <- list()
for (pop in unique_pops) {
population_matrices[[pop]] <- snp_data[pop_data == pop, ]
}
na_counts <- list()
for (pop in names(population_matrices)) {
pop_matrix <- population_matrices[[pop]]
na_count <- sum(is.na(pop_matrix))
na_counts[[pop]] <- na_count
}
na_counts
--
You received this message because you are subscribed to the Google Groups "dartR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dartr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartr/f042d200-30db-4718-8d6b-6fa9b6f0e8acn%40googlegroups.com.