RPubs will retire in June 2027. Your existing documents will stay accessible through December 31, 2031
and Connect Cloud is the recommended home for new publishing. Read the blog post

Recently Published

Haishan Code
MdB_TikTok
note17
3/25/2024
basal_attributes v1
Project2
Plot 1
# Install required packages install.packages(c("cluster", "ape", "poppr", "ade4")) # Load the packages library(cluster) library(ape) library(poppr) library(ade4) # Import genetic data # Read the data file into R data <- read.csv("Genetic_data.csv", header = TRUE) # Add unique identifiers to rows data$unique_id <- seq_len(nrow(data)) # Use the unique identifiers as row names row.names(data) <- data$unique_id # Remove the additional column if not needed data <- data[, -ncol(data)] # Add unique identifiers to rows data$unique_id <- 1:nrow(data) # Assuming there are no existing unique identifiers # Use the unique identifiers as row names row.names(data) <- data$unique_id # Remove the additional column if not needed genetic_data <- data[, -ncol(data)] # Load the vegan package library(vegan) # Calculate Jaccard's similarity matrix genetic_sim <- vegdist(genetic_data, method = "jaccard") # Perform UPGMA clustering genetic_cluster <- hclust(genetic_sim, method = "average") # Plot the dendrogram plot(genetic_cluster)
Document