Okay - here is a minimal reprex
#honestly this seems a bit bananas to me that I need to do lines 5-14de to get a matrix that matches to what I would read in
testing_genetic <- matrix(c(1, "-", 0.2, 0.5, 0.1, 0, "-", 0.3, 0.9, 0.8, 0.2, 0.2, "-", 0.5, "-", 0.7), nrow = 4, dimnames = list(c("A","B","C","D"), c("A","B","C","D")))
testing_genetic <- as.data.frame(testing_genetic)
testing_genetic <- droplevels(testing_genetic)
testing_genetic <- data.frame(lapply(testing_genetic, as.character), stringsAsFactors=FALSE)
testing_genetic <- tibble::rownames_to_column(testing_genetic, var=".")
#rename this column to make a matrix with both
testing_genetic[1,1] <- "A"
testing_genetic[2,1] <- "B"
testing_genetic[3,1] <- "C"
testing_genetic[4,1] <- "D"
#additional manipulation of genetic distance matrix for ultimately getting the mean number of SNPs
testing_genetic <- testing_genetic %>%
dplyr::rename( label = 1) %>% #rename columnn 1 to label for joining of data sets later
stats::na.omit()%>% #remove na
tidyr::pivot_longer(-label)%>% #convert to a three column data frame
.[which(.$label != .$name),] #remove self comparisons for this table - necessary for snp mean/median calculation.
testing_genetic <- testing_genetic%>%
replace(., .=="-", 0) #replace - with zero in the file; if zeros already infile, still works
When the above code is run I get the error -
"Error: Assigned data values must be compatible with existing data.
i Error occurred for column value.
x Can't convert double to character."
Let me know if this is not an acceptable minimum reprex