Errors in running code in vignettes:
when running code in 'phylin_tutorial.Snw'

> library(phylin)

> data(d.gen)

> data(vipers)

> data(grid)

> example(d.gen)

d.gen> data(d.gen)

d.gen> hc <- hclust(as.dist(d.gen))

d.gen> plot(hc, hang = -1, main="Vipers genetic distance tree", 
d.gen+      xlab="Samples", cex=0.7)

> example(d.gen)

d.gen> data(d.gen)

d.gen> hc <- hclust(as.dist(d.gen))

d.gen> plot(hc, hang = -1, main="Vipers genetic distance tree", 
d.gen+      xlab="Samples", cex=0.7)

> example(grid)

grid> data(grid)

grid> plot(grid, cex=0.5, asp=1, main="Grid of pixels for interpolation",
grid+      xlab="Longitude", ylab="Latitude")

> example(vipers)

vipers> data(vipers)

vipers> data(grid)

vipers> plot(grid, cex=0.5, col='lightgrey', asp=1,
vipers+      main="Vipers data", xlab="Longitude", ylab="Latitude")

vipers> points(vipers[,1:2], pch=vipers$lin)

vipers> legend(1, 38, legend=c("West", "South", "East"), pch=1:3, title="Lineages")

> r.dist <- dist(vipers[, 1:2])

> gv <- gen.variogram(r.dist, d.gen)

> plot(gv)

> gv$n
 [1]  26  65 123 115 100  90 141 138 172 156 112  74  76  56  55  52  45  24  16
[20]  14

> gv
Variogram with a single genetic distance matrix. 
  observations and 20 distance classes (from 0.01 to 11.74 ) 
 0.59 lag size with 0.3 tolerance. 
 No model fitted 

> summary(gv)


Summary for gv 


Number of samples:   

Variogram parameters 

   lag:              0.595 

   lag tolerance:    0.297 

   maximum distance: 11.739 

   lags with data:   20 

   semi-variance summary: 

     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.0002277 0.0013822 0.0033705 0.0027743 0.0041932 0.0041932 


No model found. 

> gv <- gv.model(gv)

> plot(gv)

> gv2 <- gv.model(gv, range = 8)

> gv.linear <- gv.model(gv, model = "linear", range = 8)

> layout(matrix(1:2, 1, 2))

> plot(gv2)

> plot(gv.linear)

> gv
Variogram with a single genetic distance matrix. 
  observations and 20 distance classes (from 0.01 to 11.74 ) 
 0.59 lag size with 0.3 tolerance. 
 A spherical model is fitted with 0.00426559266596081 sill, 10.3211400885226 range and 0 nugget. 

> summary(gv)


Summary for gv 


Number of samples:   

Variogram parameters 

   lag:              0.595 

   lag tolerance:    0.297 

   maximum distance: 11.739 

   lags with data:   20 

   semi-variance summary: 

     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.0002277 0.0013822 0.0033705 0.0027743 0.0041932 0.0041932 


Semivariogram with NA model (R squared = 0.9804)

Model parameters: 

   sill:   0.004 

   range:  10.321 

   nugget: 0 

> lin <- as.integer(vipers$lin == 1)

> int.krig <- krig(lin, vipers[, 1:2], grid, gv, neg.weights = FALSE, 
+     verbose = FALSE)

> grid.image(int.krig, grid, main = "Kriging with genetic distances", 
+     xlab = "Longitude", ylab = "Latitude", sclab = "Lineage interpolation")

> points(vipers[, 1:2], pch = lin + 1)

> grid.image(int.krig, grid, ic = "sd", main = "Kriging with genetic distances", 
+     xlab = "Longitude", ylab = "Latitude", sclab = "Standard Devia ..." ... [TRUNCATED] 

> lin.krig <- as.integer(int.krig$Z > 0.95)

> grid.image(lin.krig, grid, main = "Kriging with genetic distances", 
+     xlab = "Longitude", ylab = "Latitude", sclab = "Lineage presence")

> points(vipers[, 1:2], pch = lin + 1)

> regSampling <- seq(0.01, 0.08, 0.005)

> nodeSampling <- hc$height[hc$height > 0.01 & hc$height < 
+     max(hc$height)]

> singleSampling <- 0.06

> length(regSampling)
[1] 15

> length(nodeSampling)
[1] 15

> length(singleSampling)
[1] 1

> layout(matrix(1:3, 1, 3))

> plot(hc, hang = -1, labels = FALSE, main = "Regular sampling")

> abline(h = regSampling, col = "red", lty = 2)

> plot(hc, hang = -1, labels = FALSE, main = "Node sampling")

> abline(h = nodeSampling, col = "red", lty = 2)

> plot(hc, hang = -1, labels = FALSE, main = "Single threshold")

> abline(h = singleSampling, col = "red", lty = 2)

> contact = rep(0, nrow(grid))

> for (h in regSampling) {
+     lins <- cutree(hc, h = h)
+     print(paste("height =", h, ":", max(lins), "lineages"))
+     ct = rep(1, nrow(grid)) .... [TRUNCATED] 
[1] "height = 0.01 : 17 lineages"
[1] "height = 0.015 : 11 lineages"
[1] "height = 0.02 : 9 lineages"
[1] "height = 0.025 : 7 lineages"
[1] "height = 0.03 : 5 lineages"
[1] "height = 0.035 : 5 lineages"
[1] "height = 0.04 : 5 lineages"
[1] "height = 0.045 : 5 lineages"
[1] "height = 0.05 : 3 lineages"
[1] "height = 0.055 : 3 lineages"
[1] "height = 0.06 : 3 lineages"
[1] "height = 0.065 : 3 lineages"
[1] "height = 0.07 : 3 lineages"
[1] "height = 0.075 : 3 lineages"
[1] "height = 0.08 : 2 lineages"

> krg$Z <- contact/length(regSampling)

> grid.image(krg, grid, main = "Potential contact zones / Regular sampling", 
+     xlab = "Longitude", ylab = "Latitude", sclab = "Prob. of multiple  ..." ... [TRUNCATED] 

> points(vipers[, 1:2], cex = 0.5)

> contact = rep(0, nrow(grid))

> for (h in nodeSampling) {
+     lins <- cutree(hc, h = h)
+     print(paste("height =", h, ":", max(lins), "lineages"))
+     ct = rep(1, nrow(grid) .... [TRUNCATED] 
[1] "height = 0.0100531069115871 : 16 lineages"
[1] "height = 0.0110109618827377 : 15 lineages"
[1] "height = 0.0111452791240147 : 14 lineages"
[1] "height = 0.0120634616550434 : 13 lineages"
[1] "height = 0.0121196073198832 : 12 lineages"
[1] "height = 0.0133548759566715 : 11 lineages"
[1] "height = 0.0160592664153485 : 10 lineages"
[1] "height = 0.0187842404939693 : 9 lineages"
[1] "height = 0.022442932020887 : 8 lineages"
[1] "height = 0.0229823504675421 : 7 lineages"
[1] "height = 0.0262214807701606 : 6 lineages"
[1] "height = 0.0284351018523487 : 5 lineages"
[1] "height = 0.045540107404997 : 4 lineages"
[1] "height = 0.048234516958013 : 3 lineages"
[1] "height = 0.0756610784138512 : 2 lineages"

> krg$Z <- contact/length(nodeSampling)

> grid.image(krg, grid, main = "Potential contact zones / Node sampling", 
+     xlab = "Longitude", ylab = "Latitude", sclab = "Prob. of multiple lin ..." ... [TRUNCATED] 

> points(vipers[, 1:2], cex = 0.5)

> contact = rep(0, nrow(grid))

> for (h in singleSampling) {
+     lins <- cutree(hc, h = h)
+     print(paste("height =", h, ":", max(lins), "lineages"))
+     ct = rep(1, nrow(gri .... [TRUNCATED] 
[1] "height = 0.06 : 3 lineages"

> krg$Z <- contact/length(singleSampling)

> grid.image(krg, grid, main = "Potential contact zones / single threshold", 
+     xlab = "Longitude", ylab = "Latitude", sclab = "Prob. of multiple  ..." ... [TRUNCATED] 

> points(vipers[, 1:2], cex = 0.5)

> mp <- midpoints(vipers[, 1:2])

  When sourcing 'phylin_tutorial.R':
Error: Package 'geometry' is needed for Delaunay triangulation.
Execution halted
when running code in 'resistance_tutorial.Snw'

> library(phylin)

> data(simulations)

> size <- (simul.env$env.sur - min(simul.env$env.sur))/10

> grid.full <- simul.env[, 1:2]

> plot(grid.full, cex = size)

> points(simul.sample[, 1:2], col = simul.sample$lineage, 
+     pch = 16)

> grid <- grid.full[abs(grid.full$x) < 1.05 & abs(grid.full$y) < 
+     1.05, ]

> plot(hclust(simul.gen.dist, method = "average"), labels = FALSE)

> abline(h = 1.25, col = "red", lty = 2)

> geo.dist <- dist(simul.sample[, 1:2])

> conductance <- 1/(1 + exp(-1 * (simul.env$env.sur - 
+     5)))

> plot(simul.env$env.sur, conductance, cex = 0.25, xlab = "Environmental surface", 
+     ylab = "Conductance")

> library(gdistance)

  When sourcing 'resistance_tutorial.R':
Error: there is no package called 'gdistance'
Execution halted

  'phylin_tutorial.Snw' using 'UTF-8'... failed
  'resistance_tutorial.Snw' using 'UTF-8'... failed