x <- t(c(1L,1L,1L,2L))
colnames(x) <- c("locus1.1","locus1.2","locus2.1","locus2.2")
homozygous(x,markers = "locus1") # TRUE
homozygous(x,markers = "locus2") # FALSE
homozygous(x) # t(c(TRUE,FALSE))
y <- t(c(1L,NA,1L,2L))
colnames(y) <- c("locus1.1","locus1.2","locus2.1","locus2.2")
homozygous(y,markers = "locus1") # NA
homozygous(y,markers = "locus2") # FALSE
homozygous(y) # t(c(NA,FALSE))
heterozygous(y) # t(c(NA,TRUE))
Run the code above in your browser using DataLab