R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("Malmig-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('Malmig') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "Fst" > > ### * Fst > > flush(stderr()); flush(stdout()) > > ### Name: Fst > ### Title: Calculates the Fst from the conditional kinship matrix > ### Aliases: Fst > ### Keywords: array manip misc > > ### ** Examples > > # Swedlund data again... > data(P); data(S); data(N) > # starting with how many cycles to equilibrium > x<-Mal.eq(S,P,N) > # calculation of phi > phi<-Phi(S,P,N,x) > # calcutaion of the conditional kinship matrix > cond<-R(phi,N) > # finally! we get the Fst value > fst<-Fst(cond,N) > fst [,1] [1,] 0.0002614661 > > > > cleanEx(); ..nameEx <- "Lasker" > > ### * Lasker > > flush(stderr()); flush(stdout()) > > ### Name: Lasker > ### Title: Calculates the Lasker kinship coeffcient > ### Aliases: Lasker > ### Keywords: array methods manip > > ### ** Examples > > data(surnames) > surnames #a made-up dateset Population Cognome Due Tre Uno alfa 4 4 7 beta 2 0 4 chi 6 2 0 delta 0 0 3 epsilon 0 0 2 eta 0 4 0 gamma 5 0 3 lambda 0 1 0 omega 0 5 0 teta 4 0 0 > > # you can see that the surnames are arranged as the _rows_ and the populations are the _columns_ > # the use of the function ``Lasker'' just turns this data into a kinship matrix > > lask.kin <- Lasker(surnames) > lask.kin [,1] [,2] [,3] [1,] 0.10997732 0.04166667 0.06390977 [2,] 0.04166667 0.12109375 0.04605263 [3,] 0.06390977 0.04605263 0.12049861 > > > > cleanEx(); ..nameEx <- "Mal.eq" > > ### * Mal.eq > > flush(stderr()); flush(stdout()) > > ### Name: Mal.eq > ### Title: Calculates the asymptotic generation for the Malecot model > ### Aliases: Mal.eq > ### Keywords: array iteration methods > > ### ** Examples > > # the data is originally from a paper by Swedlund et al. 1984. > data(S); data(P); data(N) > Mal.eq(S,P,N) [1] 26 > > > > cleanEx(); ..nameEx <- "N" > > ### * N > > flush(stderr()); flush(stdout()) > > ### Name: N > ### Title: Effective population vector > ### Aliases: N > ### Keywords: datasets > > ### ** Examples > > data(N) > > > > cleanEx(); ..nameEx <- "P" > > ### * P > > flush(stderr()); flush(stdout()) > > ### Name: P > ### Title: Column stochastic migration matrix > ### Aliases: P > ### Keywords: datasets > > ### ** Examples > > data(P) > > > > cleanEx(); ..nameEx <- "Phi" > > ### * Phi > > flush(stderr()); flush(stdout()) > > ### Name: Phi > ### Title: Calculates a kinship matrix using the Malecot Migration Model > ### Aliases: Phi > ### Keywords: array iteration > > ### ** Examples > > # using Swedlund data again... > data(S); data(P); data(N) > x<-Mal.eq(S,P,N) > phi<-Phi(S,P,N,x) > phi [,1] [,2] [,3] [,4] [,5] [1,] 1.717564e-04 6.347189e-05 9.155242e-05 2.655827e-05 6.747329e-05 [2,] 6.347189e-05 2.335585e-04 7.617680e-05 1.699248e-05 2.076309e-05 [3,] 9.155242e-05 7.617680e-05 7.076472e-04 1.324091e-04 7.984983e-05 [4,] 2.655827e-05 1.699248e-05 1.324091e-04 4.596008e-04 8.823091e-05 [5,] 6.747329e-05 2.076309e-05 7.984983e-05 8.823091e-05 1.793885e-04 [6,] 2.934528e-05 1.208167e-05 6.396092e-05 1.455852e-04 1.208996e-04 [7,] 1.806841e-05 1.745242e-05 4.929063e-05 6.338900e-05 2.313809e-05 [8,] 4.885315e-05 4.141629e-05 3.787200e-05 8.555855e-06 1.569964e-05 [9,] 2.978833e-05 1.083144e-04 6.519210e-05 1.575404e-05 1.982458e-05 [10,] 3.402295e-05 9.201112e-05 7.144976e-05 2.515097e-05 1.414615e-05 [11,] 3.950278e-05 1.097852e-04 5.116530e-05 2.381344e-05 1.336668e-05 [12,] 2.801755e-05 4.261294e-05 1.302071e-04 8.279048e-05 3.209491e-05 [,6] [,7] [,8] [,9] [,10] [1,] 2.934528e-05 1.806841e-05 4.885315e-05 2.978833e-05 3.402295e-05 [2,] 1.208167e-05 1.745242e-05 4.141629e-05 1.083144e-04 9.201112e-05 [3,] 6.396092e-05 4.929063e-05 3.787200e-05 6.519210e-05 7.144976e-05 [4,] 1.455852e-04 6.338900e-05 8.555855e-06 1.575404e-05 2.515097e-05 [5,] 1.208996e-04 2.313809e-05 1.569964e-05 1.982458e-05 1.414615e-05 [6,] 2.532518e-04 1.695921e-05 1.030340e-05 1.317142e-05 1.073495e-05 [7,] 1.695921e-05 4.390693e-04 6.554656e-06 1.772447e-05 3.179634e-05 [8,] 1.030340e-05 6.554656e-06 2.000647e-04 5.294608e-05 2.264994e-05 [9,] 1.317142e-05 1.772447e-05 5.294608e-05 4.575556e-04 1.133898e-04 [10,] 1.073495e-05 3.179634e-05 2.264994e-05 1.133898e-04 8.986540e-04 [11,] 7.942399e-06 1.181872e-05 3.024216e-05 1.946476e-04 1.858834e-04 [12,] 2.825087e-05 1.227191e-04 1.709454e-05 2.631520e-05 1.098216e-04 [,11] [,12] [1,] 3.950278e-05 2.801755e-05 [2,] 1.097852e-04 4.261294e-05 [3,] 5.116530e-05 1.302071e-04 [4,] 2.381344e-05 8.279048e-05 [5,] 1.336668e-05 3.209491e-05 [6,] 7.942399e-06 2.825087e-05 [7,] 1.181872e-05 1.227191e-04 [8,] 3.024216e-05 1.709454e-05 [9,] 1.946476e-04 2.631520e-05 [10,] 1.858834e-04 1.098216e-04 [11,] 3.837094e-04 3.609761e-05 [12,] 3.609761e-05 2.324434e-04 > > > > cleanEx(); ..nameEx <- "R" > > ### * R > > flush(stderr()); flush(stdout()) > > ### Name: R > ### Title: Calculates a Conditional Kinship matrix > ### Aliases: R > ### Keywords: array manip > > ### ** Examples > > # using Swedlund data again... > data(S); data(P); data(N) > x<-Mal.eq(S,P,N) > phi<-Phi(S,P,N,x) > cond.mat<-R(phi,N) > cond.mat [,1] [,2] [,3] [,4] [,5] [1,] 1.212487e-04 6.591121e-06 -2.283357e-05 -5.009277e-05 1.384530e-05 [2,] 6.591121e-06 1.703250e-04 -4.457553e-05 -6.602449e-05 -3.923354e-05 [3,] -2.283357e-05 -4.457553e-05 5.294337e-04 -8.106680e-06 -3.764976e-05 [4,] -5.009277e-05 -6.602449e-05 -8.106680e-06 3.568485e-04 8.471616e-06 [5,] 1.384530e-05 -3.923354e-05 -3.764976e-05 8.471616e-06 1.226559e-04 [6,] -2.652600e-05 -5.015609e-05 -5.578033e-05 6.358955e-05 6.192222e-05 [7,] -2.718103e-05 -3.416229e-05 -5.982903e-05 -7.989949e-06 -2.522373e-05 [8,] 2.042605e-05 6.623427e-06 -5.442839e-05 -4.600699e-05 -1.584262e-05 [9,] -3.199855e-05 4.016801e-05 -6.046470e-05 -7.216668e-05 -4.507578e-05 [10,] -6.167416e-05 -1.004698e-05 -8.811711e-05 -9.667959e-05 -8.466515e-05 [11,] -2.242400e-05 4.149834e-05 -7.463312e-05 -6.424730e-05 -5.167476e-05 [12,] -3.523600e-05 -2.700477e-05 3.088470e-06 -6.591887e-06 -3.427109e-05 [,6] [,7] [,8] [,9] [,10] [1,] -2.652600e-05 -2.718103e-05 2.042605e-05 -3.199855e-05 -6.167416e-05 [2,] -5.015609e-05 -3.416229e-05 6.623427e-06 4.016801e-05 -1.004698e-05 [3,] -5.578033e-05 -5.982903e-05 -5.442839e-05 -6.046470e-05 -8.811711e-05 [4,] 6.358955e-05 -7.989949e-06 -4.600699e-05 -7.216668e-05 -9.667959e-05 [5,] 6.192222e-05 -2.522373e-05 -1.584262e-05 -4.507578e-05 -8.466515e-05 [6,] 1.920436e-04 -3.364355e-05 -2.347975e-05 -5.396993e-05 -9.031710e-05 [7,] -3.364355e-05 3.991200e-04 -1.660611e-05 -3.879388e-05 -5.863151e-05 [8,] -2.347975e-05 -1.660611e-05 1.937382e-04 1.325040e-05 -5.095847e-05 [9,] -5.396993e-05 -3.879388e-05 1.325040e-05 3.845310e-04 6.429577e-06 [10,] -9.031710e-05 -5.863151e-05 -5.095847e-05 6.429577e-06 7.578406e-04 [11,] -5.933993e-05 -4.484067e-05 -9.595777e-06 1.214632e-04 7.878785e-05 [12,] -4.035591e-05 6.474187e-05 -2.407029e-05 -4.820735e-05 1.394607e-06 [,11] [,12] [1,] -2.242400e-05 -3.523600e-05 [2,] 4.149834e-05 -2.700477e-05 [3,] -7.463312e-05 3.088470e-06 [4,] -6.424730e-05 -6.591887e-06 [5,] -5.167476e-05 -3.427109e-05 [6,] -5.933993e-05 -4.035591e-05 [7,] -4.484067e-05 6.474187e-05 [8,] -9.595777e-06 -2.407029e-05 [9,] 1.214632e-04 -4.820735e-05 [10,] 7.878785e-05 1.394607e-06 [11,] 3.103983e-04 -3.856484e-05 [12,] -3.856484e-05 1.564693e-04 > > > > cleanEx(); ..nameEx <- "S" > > ### * S > > flush(stderr()); flush(stdout()) > > ### Name: S > ### Title: Systematic pressure matrix > ### Aliases: S > ### Keywords: datasets > > ### ** Examples > > data(S) > > > > cleanEx(); ..nameEx <- "col.sto" > > ### * col.sto > > flush(stderr()); flush(stdout()) > > ### Name: col.sto > ### Title: Turns a Migration Matrix into a Column Stochastic Matrix > ### Aliases: col.sto > ### Keywords: manip array > > ### ** Examples > > data(raw.mig) > new.mig.mat<-col.sto(raw.mig) > new.mig.mat [,1] [,2] [,3] [,4] [1,] 0.80000000 0.07142857 0.0000 0.00000000 [2,] 0.13333333 0.78571429 0.0000 0.07142857 [3,] 0.00000000 0.00000000 0.9375 0.00000000 [4,] 0.06666667 0.14285714 0.0625 0.92857143 > > > > cleanEx(); ..nameEx <- "mtx.exp" > > ### * mtx.exp > > flush(stderr()); flush(stdout()) > > ### Name: mtx.exp > ### Title: Calculates the n-th power of a matrix > ### Aliases: mtx.exp > ### Keywords: array manip methods > > ### ** Examples > > test<-matrix(c(1:16), 4,4) > pow.test<-mtx.exp(test,10) > pow.test [,1] [,2] [,3] [,4] [1,] 2.568153e+14 5.933637e+14 9.299121e+14 1.266461e+15 [2,] 2.908200e+14 6.719305e+14 1.053041e+15 1.434152e+15 [3,] 3.248247e+14 7.504974e+14 1.176170e+15 1.601843e+15 [4,] 3.588295e+14 8.290642e+14 1.299299e+15 1.769534e+15 > > > > cleanEx(); ..nameEx <- "raw.mig" > > ### * raw.mig > > flush(stderr()); flush(stdout()) > > ### Name: raw.mig > ### Title: A raw migration data > ### Aliases: raw.mig > ### Keywords: datasets > > ### ** Examples > > data(raw.mig) > col.sto(raw.mig) [,1] [,2] [,3] [,4] [1,] 0.80000000 0.07142857 0.0000 0.00000000 [2,] 0.13333333 0.78571429 0.0000 0.07142857 [3,] 0.00000000 0.00000000 0.9375 0.00000000 [4,] 0.06666667 0.14285714 0.0625 0.92857143 > > > > cleanEx(); ..nameEx <- "surnames" > > ### * surnames > > flush(stderr()); flush(stdout()) > > ### Name: surnames > ### Title: Isonymy matrix data > ### Aliases: surnames > ### Keywords: datasets > > ### ** Examples > > data(surnames) > # NB. How did we produce the "surnames" dataset? > # the original data [note, the following is a crop] was arranged as: > > #Population Surname > # Uno alfa > # Uno beta > # Uno alfa > # Uno gamma > # Uno delta > # Uno alfa > # Uno delta > # Uno alfa > # Uno alfa > # Due chi > # Due chi > # Due chi > # Due chi > # Due chi > # Due teta > # Due beta > # Due chi > # Due gamma > # Due teta > # Due teta > # Tre lambda > # Tre alfa > # Tre chi > # Tre chi > # Tre alfa > # Tre alfa > # Tre alfa > # .......... > > # This arrangement does not necessarily reflect the way other people would arrange their data; > # so it had to be transformed by t(table(data)) to get the "surnames" dataset in its present and "correct" form > > > > cleanEx(); ..nameEx <- "sym.P" > > ### * sym.P > > flush(stderr()); flush(stdout()) > > ### Name: sym.P > ### Title: Calculate the symmetric column stochastic matrix > ### Aliases: sym.P > ### Keywords: array manip > > ### ** Examples > > data(P) > symmetric<-sym.P(P) > > > > ### *