# create a file to read (usually done with spreadsheet software or a
# text editor):
cat("// here's a comment line at the beginning of the file",
"5t0t-2t2t2t4",
"4t5t10t50t100",
"IndtLattLongtloc1tloc2",
"ind1t39.5t-120.8t00003133t00004040",
"ind2t39.5t-120.8t3537t4246",
"ind3t42.6t-121.1t5083332t40414500",
"ind4t38.2t-120.3t00000000t41430000",
"ind5t38.2t-120.3t00053137t00414200",
"END",
sep="", file="SpagInputExample.txt")
# display the file
cat(readLines("SpagInputExample.txt"), sep="")
# read the file
mydata <- read.SPAGeDi("SpagInputExample.txt", allelesep = "",
returncatspatcoord = TRUE, returnploidies = TRUE)
# view the data
mydata
# view genotypes by locus
mydata$Genotypes[,"loc1"]
mydata$Genotypes[,"loc2"]
Run the code above in your browser using DataLab