From noreply at r-forge.r-project.org Wed Dec 3 11:45:38 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Wed, 3 Dec 2014 11:45:38 +0100 (CET)
Subject: [Vegan-commits] r2914 - in pkg/vegan: . R inst
Message-ID: <20141203104538.860511864EC@r-forge.r-project.org>
Author: jarioksa
Date: 2014-12-03 11:45:38 +0100 (Wed, 03 Dec 2014)
New Revision: 2914
Modified:
pkg/vegan/NAMESPACE
pkg/vegan/R/orditkplot.R
pkg/vegan/inst/NEWS.Rd
Log:
Squashed commit of the following:
commit 53ba696282e13884d71c54143fdc07a368b26ec1
Author: Jari Oksanen
Date: Mon Dec 1 14:10:57 2014 +0200
Do not import namespace of tcltk
We need tcltk in one function (orditkplot) and DESCRIPTION only
suggests the package. However, NAMESPACE has import(tcltk) and if
tcltk is missing, loading vegan will fail. Now we omit tcltk import
from the NAMESPACE, and orditkplot uses explicith tcltk:: prefix for
all ca. 125 tcltk commands so that vegan can be used without tcltk
package (except for orditlplot)
I had seen this occasionally in some R builds, but the change was
triggered by queries from Dave Roberts.
(cherry picked from commit 2defbae459c0ca0b241dcc48442a4341e6c45564)
commit 099114797874ebb596ab7fb1b6fbebcae4af538c
Author: Gavin Simpson
Date: Sat Nov 22 19:40:24 2014 -0600
use seq_along(x) instead of 1:length(x)
(cherry picked from commit 2fa9b5d7725bd4dba44741dc607841058e17ff85)
commit 4232fab8f09f6ae37275aef7f9bc5b408953a109
Author: Jari Oksanen
Date: Tue Dec 2 18:46:03 2014 +0200
NEWS on changes in 2.2-1
Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE 2014-11-24 10:44:01 UTC (rev 2913)
+++ pkg/vegan/NAMESPACE 2014-12-03 10:45:38 UTC (rev 2914)
@@ -77,7 +77,6 @@
importFrom(tools, Rd2txt, startDynamicHelp)
import(lattice)
import(parallel)
-import(tcltk)
importFrom(MASS, isoMDS, sammon, Shepard, mvrnorm)
importFrom(cluster, daisy)
## 's' must be imported in mgcv < 1.8-0 (not needed later)
Modified: pkg/vegan/R/orditkplot.R
===================================================================
--- pkg/vegan/R/orditkplot.R 2014-11-24 10:44:01 UTC (rev 2913)
+++ pkg/vegan/R/orditkplot.R 2014-12-03 10:45:38 UTC (rev 2914)
@@ -13,7 +13,7 @@
############################
### Check and sanitize input
###########################
-
+
## Graphical parameters and constants, and save some for later plotting
p <- par()
sparnam <- c("bg","cex", "cex.axis","cex.lab","col", "col.axis", "col.lab",
@@ -36,7 +36,7 @@
}
savepar <- p[sparnam]
PPI <- 72 # Points per Inch
- p2p <- as.numeric(tclvalue(tcl("tk", "scaling"))) # Pixel per point
+ p2p <- as.numeric(tcltk::tclvalue(tcltk::tcl("tk", "scaling"))) # Pixel per point
DIAM <- 2.7 # diam of plotting symbol
## Plotting symbol diam
diam <- round(pcex * DIAM * p2p, 1)
@@ -47,7 +47,7 @@
x <- gsub("transparent", "", x)
x[is.na(x)] <- ""
x
- }
+ }
p$bg <- sanecol(p$bg)
p$fg <- sanecol(p$fg)
p$col <- sanecol(p$col)
@@ -86,13 +86,13 @@
"0" = Point(x, y, 22, col, fill = "", diam),
"1" = Point(x, y, 21, col, fill = "", diam),
"2" = Point(x, y, 24, col, fill = "", diam),
- "3" = {tkcreate(can, "line",
+ "3" = {tcltk::tkcreate(can, "line",
x, y+SQ*diam, x, y-SQ*diam, fill=col)
- tkcreate(can, "line",
+ tcltk::tkcreate(can, "line",
x+SQ*diam, y, x-SQ*diam, y, fill=col)},
- "4" = {tkcreate(can, "line",
+ "4" = {tcltk::tkcreate(can, "line",
x-diam, y-diam, x+diam, y+diam, fill=col)
- tkcreate(can, "line",
+ tcltk::tkcreate(can, "line",
x-diam, y+diam, x+diam, y-diam, fill=col)},
"5" = Point(x, y, 23, col, fill = "", diam),
"6" = Point(x, y, 25, col, fill = "", diam),
@@ -110,9 +110,9 @@
Point(x, y, 0, col, fill, diam)},
"13" = {Point(x, y, 4, col, fill, diam)
Point(x, y, 1, col, fill, diam)},
- "14" = {tkcreate(can, "line", x-diam, y-diam, x, y+diam,
+ "14" = {tcltk::tkcreate(can, "line", x-diam, y-diam, x, y+diam,
fill = col)
- tkcreate(can, "line", x+diam, y-diam, x, y+diam,
+ tcltk::tkcreate(can, "line", x+diam, y-diam, x, y+diam,
fill = col)
Point(x, y, 0, col, fill, diam)},
"15" = Point(x, y, 22, col = col, fill = col, diam),
@@ -121,22 +121,22 @@
"18" = Point(x, y, 23, col = col, fill = col, diam/SQ),
"19" = Point(x, y, 21, col = col, fill = col, diam),
"20" = Point(x, y, 21, col = col, fill = col, diam/2),
- "21" = tkcreate(can, "oval", x-diam, y-diam,
+ "21" = tcltk::tkcreate(can, "oval", x-diam, y-diam,
x+diam, y+diam, outline = col, fill = fill),
- "22" = tkcreate(can, "rectangle", x-diam, y-diam,
+ "22" = tcltk::tkcreate(can, "rectangle", x-diam, y-diam,
x+diam, y+diam, outline = col, fill = fill),
- "23" = tkcreate(can, "polygon", x, y+SQ*diam,
+ "23" = tcltk::tkcreate(can, "polygon", x, y+SQ*diam,
x+SQ*diam, y, x, y-SQ*diam, x-SQ*diam, y,
outline = col, fill = fill),
- "24" = tkcreate(can, "polygon", x, y-SQ*diam,
+ "24" = tcltk::tkcreate(can, "polygon", x, y-SQ*diam,
x+sqrt(6)/2*diam, y+SQ/2*diam, x-sqrt(6)/2*diam, y+SQ/2*diam,
outline = col, fill = fill),
- "25" = tkcreate(can, "polygon", x, y+SQ*diam,
+ "25" = tcltk::tkcreate(can, "polygon", x, y+SQ*diam,
x+sqrt(6)/2*diam, y-SQ/2*diam, x-sqrt(6)/2*diam, y-SQ/2*diam,
outline = col, fill = fill),
"o" = Point(x, y, 1, col, fill, diam),
## default: text with dummy location of the label
- {tkcreate(can, "text",
+ {tcltk::tkcreate(can, "text",
x, y, text = as.character(pch), fill = col)
Point(x, y, 21, col="", fill="", diam)}
)
@@ -147,31 +147,33 @@
############################
## toplevel
- w <- tktoplevel()
- tktitle(w) <- deparse(match.call())
+ w <- tcltk::tktoplevel()
+ tcltk::tktitle(w) <- deparse(match.call())
## Max dim of windows (depends on screen)
- YSCR <- as.numeric(tkwinfo("screenheight", w)) - 150
- XSCR <- as.numeric(tkwinfo("screenwidth", w))
+ YSCR <- as.numeric(tcltk::tkwinfo("screenheight", w)) - 150
+ XSCR <- as.numeric(tcltk::tkwinfo("screenwidth", w))
################################
### Buttons and button functions
################################
## Buttons
- buts <- tkframe(w)
+ buts <- tcltk::tkframe(w)
## Copy current canvas to EPS using the standard Tcl/Tk utility
- cp2eps <- tkbutton(buts, text="Copy to EPS",
- command=function() tkpostscript(can, x=0, y=0,
- height=height, width=width,
- file=tkgetSaveFile(filetypes="{{EPS file} {.eps}}")))
- dismiss <- tkbutton(buts, text="Dismiss", command=function() tkdestroy(w))
+ cp2eps <- tcltk::tkbutton(buts, text="Copy to EPS",
+ command=function() tcltk::tkpostscript(can, x=0, y=0,
+ height=height, width=width,
+ file=tcltk::tkgetSaveFile(
+ filetypes="{{EPS file} {.eps}}")))
+ dismiss <- tcltk::tkbutton(buts, text="Dismiss",
+ command=function() tcltk::tkdestroy(w))
## Dump current plot to an "orditkplot" object (internally)
ordDump <- function() {
xy <- matrix(0, nrow=nrow(sco), ncol=2)
rownames(xy) <- rownames(sco)
colnames(xy) <- colnames(sco)
for(nm in names(pola)) {
- xy[as.numeric(tclvalue(id[[nm]])),] <- xy2usr(nm)
+ xy[as.numeric(tcltk::tclvalue(id[[nm]])),] <- xy2usr(nm)
}
curdim <- round(c(width, height) /PPI/p2p, 2)
## Sanitize colours for R plot
@@ -191,37 +193,37 @@
dim = curdim)
class(xy) <- "orditkplot"
xy
- }
+ }
## Button to dump "orditkplot" object to the R session
pDump <- function() {
xy <- ordDump()
- dumpVar <- tclVar("")
- tt <- tktoplevel()
- tktitle(tt) <- "R Dump"
- entryDump <- tkentry(tt, width=20, textvariable=dumpVar)
- tkgrid(tklabel(tt, text="Enter name for an R object"))
- tkgrid(entryDump, pady="5m")
+ dumpVar <- tcltk::tclVar("")
+ tt <- tcltk::tktoplevel()
+ tcltk::tktitle(tt) <- "R Dump"
+ entryDump <- tcltk::tkentry(tt, width=20, textvariable=dumpVar)
+ tcltk::tkgrid(tcltk::tklabel(tt, text="Enter name for an R object"))
+ tcltk::tkgrid(entryDump, pady="5m")
isDone <- function() {
- dumpName <- tclvalue(dumpVar)
+ dumpName <- tcltk::tclvalue(dumpVar)
if (exists(dumpName, envir=.GlobalEnv)) {
- ok <- tkmessageBox(message=paste(sQuote(dumpName),
+ ok <- tcltk::tkmessageBox(message=paste(sQuote(dumpName),
"exists.\nOK to overwrite?"),
icon="warning", type="okcancel",
default="ok")
- if(tclvalue(ok) == "ok") {
+ if(tcltk::tclvalue(ok) == "ok") {
assign(dumpName, xy, envir=.GlobalEnv)
- tkdestroy(tt)
+ tcltk::tkdestroy(tt)
}
}
else {
assign(dumpName, xy, envir=.GlobalEnv)
- tkdestroy(tt)
+ tcltk::tkdestroy(tt)
}
}
- tkbind(entryDump, "", isDone)
- tkfocus(tt)
+ tcltk::tkbind(entryDump, "", isDone)
+ tcltk::tkfocus(tt)
}
- dump <- tkbutton(buts, text="Dump to R", command=pDump)
+ dump <- tcltk::tkbutton(buts, text="Dump to R", command=pDump)
## Button to write current "orditkplot" object to a graphical device
devDump <- function() {
xy <- ordDump()
@@ -242,10 +244,10 @@
if (!isTRUE(unname(capabilities("tiff"))))
falt["tiff"] <- FALSE
ftypes <- ftypes[falt]
- fname <- tkgetSaveFile(filetypes=ftypes)
- if(tclvalue(fname) == "")
+ fname <- tcltk::tkgetSaveFile(filetypes=ftypes)
+ if(tcltk::tclvalue(fname) == "")
return(NULL)
- fname <- tclvalue(fname)
+ fname <- tcltk::tclvalue(fname)
ftype <- unlist(strsplit(fname, "\\."))
ftype <- ftype[length(ftype)]
if (ftype == "jpeg")
@@ -254,7 +256,7 @@
ftype <- "tiff"
mess <- "is not a supported type: file not produced. Supported types are"
if (!(ftype %in% names(ftypes))) {
- tkmessageBox(message=paste(sQuote(ftype), mess, paste(names(ftypes),
+ tcltk::tkmessageBox(message=paste(sQuote(ftype), mess, paste(names(ftypes),
collapse=", ")), icon="warning")
return(NULL)
}
@@ -272,19 +274,19 @@
plot.orditkplot(xy)
dev.off()
}
- export <- tkbutton(buts, text="Export plot", command=devDump)
+ export <- tcltk::tkbutton(buts, text="Export plot", command=devDump)
##########
### Canvas
##########
-
+
## Make canvas
sco <- try(scores(x, display=display, choices = choices, ...),
silent = TRUE)
if (inherits(sco, "try-error")) {
- tkmessageBox(message=paste("No ordination scores were found in",
+ tcltk::tkmessageBox(message=paste("No ordination scores were found in",
sQuote(deparse(substitute(x)))), icon="error")
- tkdestroy(w)
+ tcltk::tkdestroy(w)
stop("argument x did not contain ordination scores")
}
if (!missing(labels))
@@ -325,13 +327,13 @@
ylim <- range(sco[,2], na.rm = TRUE)
xpretty <- pretty(xlim)
ypretty <- pretty(ylim)
- ## Extend ranges by 4%
+ ## Extend ranges by 4%
xrange <- c(-0.04, 0.04) * diff(xlim) + xlim
xpretty <- xpretty[xpretty >= xrange[1] & xpretty <= xrange[2]]
yrange <- c(-0.04, 0.04) * diff(ylim) + ylim
ypretty <- ypretty[ypretty >= yrange[1] & ypretty <= yrange[2]]
## Canvas like they were in the default devices when I last checked
- if (missing(width))
+ if (missing(width))
width <- p$din[1]
width <- width * PPI * p2p
## Margin row width also varies with platform and devices
@@ -350,11 +352,11 @@
}
## User coordinates of an item
xy2usr <- function(item) {
- xy <- as.numeric(tkcoords(can, item))
- x <- xy[1]
- y <- xy[2]
- x <- xrange[1] + (x - mar[2])/xincr
- y <- yrange[2] - (y - mar[3])/yincr
+ xy <- as.numeric(tcltk::tkcoords(can, item))
+ x <- xy[1]
+ y <- xy[2]
+ x <- xrange[1] + (x - mar[2])/xincr
+ y <- yrange[2] - (y - mar[3])/yincr
c(x,y)
}
## Canvas x or y to user coordinates
@@ -368,49 +370,51 @@
height <- round((diff(yrange)/diff(xrange)) * xusr)
height <- height + mar[1] + mar[3]
## Canvas, finally
- can <- tkcanvas(w, relief="sunken", width=width, height=min(height,YSCR),
+ can <- tcltk::tkcanvas(w, relief="sunken", width=width, height=min(height,YSCR),
scrollregion=c(0,0,width,height))
if (p$bg != "")
- tkconfigure(can, bg=p$bg)
- yscr <- tkscrollbar(w, command = function(...) tkyview(can, ...))
- tkconfigure(can, yscrollcommand = function(...) tkset(yscr, ...))
+ tcltk::tkconfigure(can, bg=p$bg)
+ yscr <- tcltk::tkscrollbar(w, command =
+ function(...) tcltk::tkyview(can, ...))
+ tcltk::tkconfigure(can, yscrollcommand =
+ function(...) tcltk::tkset(yscr, ...))
## Pack it up
- tkpack(buts, side="bottom", fill="x", pady="2m")
- tkpack(can, side="left", fill="x")
- tkpack(yscr, side="right", fill="y")
- tkgrid(cp2eps, export, dump, dismiss, sticky="s")
+ tcltk::tkpack(buts, side="bottom", fill="x", pady="2m")
+ tcltk::tkpack(can, side="left", fill="x")
+ tcltk::tkpack(yscr, side="right", fill="y")
+ tcltk::tkgrid(cp2eps, export, dump, dismiss, sticky="s")
## Box
x0 <- usr2xy(c(xrange[1], yrange[1]))
x1 <- usr2xy(c(xrange[2], yrange[2]))
- tkcreate(can, "rectangle", x0[1], x0[2], x1[1], x1[2], outline = p$fg,
+ tcltk::tkcreate(can, "rectangle", x0[1], x0[2], x1[1], x1[2], outline = p$fg,
width = p$lwd)
## Axes and ticks
tl <- -p$tcl * rpix # -p$tcl * p$ps * p2p
axoff <- p$mgp[3] * rpix
tmp <- xpretty
- for (i in 1:length(tmp)) {
+ for (i in seq_along(tmp)) {
x0 <- usr2xy(c(xpretty[1], yrange[1]))
x1 <- usr2xy(c(xpretty[length(xpretty)], yrange[1]))
- tkcreate(can, "line", x0[1], x0[2]+axoff, x1[1], x1[2]+axoff,
+ tcltk::tkcreate(can, "line", x0[1], x0[2]+axoff, x1[1], x1[2]+axoff,
fill=p$fg)
xx <- usr2xy(c(tmp[i], yrange[1]))
- tkcreate(can, "line", xx[1], xx[2] + axoff, xx[1], xx[2]+tl+axoff,
- fill=p$fg)
- tkcreate(can, "text", xx[1], xx[2] + rpix * p$mgp[2], anchor="n",
+ tcltk::tkcreate(can, "line", xx[1], xx[2] + axoff, xx[1],
+ xx[2]+tl+axoff, fill=p$fg)
+ tcltk::tkcreate(can, "text", xx[1], xx[2] + rpix * p$mgp[2], anchor="n",
text=as.character(tmp[i]), fill=p$col.axis, font=fnt.axis)
}
xx <- usr2xy(c(mean(xrange), yrange[1]))
- tkcreate(can, "text", xx[1], xx[2] + rpix * p$mgp[1],
+ tcltk::tkcreate(can, "text", xx[1], xx[2] + rpix * p$mgp[1],
text=colnames(sco)[1], fill=p$col.lab, anchor="n", font=fnt.lab)
tmp <- ypretty
- for (i in 1:length(tmp)) {
+ for (i in seq_along(tmp)) {
x0 <- usr2xy(c(xrange[1], tmp[1]))
x1 <- usr2xy(c(xrange[1], tmp[length(tmp)]))
- tkcreate(can, "line", x0[1]-axoff, x0[2], x1[1]-axoff, x1[2])
+ tcltk::tkcreate(can, "line", x0[1]-axoff, x0[2], x1[1]-axoff, x1[2])
yy <- usr2xy(c(xrange[1], tmp[i]))
- tkcreate(can, "line", yy[1]-axoff, yy[2], yy[1]-tl-axoff, yy[2],
+ tcltk::tkcreate(can, "line", yy[1]-axoff, yy[2], yy[1]-tl-axoff, yy[2],
fill=p$fg )
- tkcreate(can, "text", yy[1] - rpix * p$mgp[2] , yy[2], anchor="e",
+ tcltk::tkcreate(can, "text", yy[1] - rpix * p$mgp[2] , yy[2], anchor="e",
text=as.character(tmp[i]), fill = p$col.axis, font=fnt.axis)
}
## Points and labels
@@ -425,19 +429,19 @@
lsco <- sco
laboff <- round(p2p * p$ps/2 + diam + 1)
}
- pola <- tclArray() # points
- labtext <- tclArray() # text
- id <- tclArray() # index
+ pola <- tcltk::tclArray() # points
+ labtext <- tcltk::tclArray() # text
+ id <- tcltk::tclArray() # index
for (i in 1:nrow(sco)) {
xy <- usr2xy(sco[i,])
item <- Point(xy[1], xy[2], pch = pch[i], col = pcol[i],
fill = pbg[i], diam = diam[i])
xy <- usr2xy(lsco[i,])
fnt <- c(labfam[i], labsize[i], saneslant(labfnt[i]))
- lab <- tkcreate(can, "text", xy[1], xy[2]-laboff[i], text=labs[i],
+ lab <- tcltk::tkcreate(can, "text", xy[1], xy[2]-laboff[i], text=labs[i],
fill = tcol[i], font=fnt)
- tkaddtag(can, "point", "withtag", item)
- tkaddtag(can, "label", "withtag", lab)
+ tcltk::tkaddtag(can, "point", "withtag", item)
+ tcltk::tkaddtag(can, "label", "withtag", lab)
pola[[lab]] <- item
labtext[[lab]] <- labs[i]
id[[lab]] <- i
@@ -446,29 +450,30 @@
##############################
### Mouse operations on canvas
##############################
-
+
## Plotting and Moving
## Mouse enters a label
pEnter <- function() {
- tkdelete(can, "box")
- hbox <- tkcreate(can, "rectangle", tkbbox(can, "current"),
+ tcltk::tkdelete(can, "box")
+ hbox <- tcltk::tkcreate(can, "rectangle",
+ tcltk::tkbbox(can, "current"),
outline = "red", fill = "yellow")
- tkaddtag(can, "box", "withtag", hbox)
- tkitemraise(can, "current")
+ tcltk::tkaddtag(can, "box", "withtag", hbox)
+ tcltk::tkitemraise(can, "current")
}
## Mouse leaves a label
pLeave <- function() {
- tkdelete(can, "box")
+ tcltk::tkdelete(can, "box")
}
## Select label
pDown <- function(x, y) {
x <- as.numeric(x)
y <- as.numeric(y)
- tkdtag(can, "selected")
- tkaddtag(can, "selected", "withtag", "current")
- tkitemraise(can, "current")
- p <- as.numeric(tkcoords(can,
- pola[[tkfind(can, "withtag", "current")]]))
+ tcltk::tkdtag(can, "selected")
+ tcltk::tkaddtag(can, "selected", "withtag", "current")
+ tcltk::tkitemraise(can, "current")
+ p <- as.numeric(tcltk::tkcoords(can,
+ pola[[tcltk::tkfind(can, "withtag", "current")]]))
.pX <<- (p[1]+p[3])/2
.pY <<- (p[2]+p[4])/2
.lastX <<- x
@@ -478,40 +483,41 @@
pMove <- function(x, y) {
x <- as.numeric(x)
y <- as.numeric(y)
- tkmove(can, "selected", x - .lastX, y - .lastY)
- tkdelete(can, "ptr")
- tkdelete(can, "box")
+ tcltk::tkmove(can, "selected", x - .lastX, y - .lastY)
+ tcltk::tkdelete(can, "ptr")
+ tcltk::tkdelete(can, "box")
.lastX <<- x
.lastY <<- y
## xadj,yadj: adjust for canvas scrolling
- xadj <- as.numeric(tkcanvasx(can, 0))
- yadj <- as.numeric(tkcanvasy(can, 0))
- hbox <- tkcreate(can, "rectangle", tkbbox(can, "selected"),
- outline = "red")
- tkaddtag(can, "box", "withtag", hbox)
- conn <- tkcreate(can, "line", .lastX + xadj, .lastY+yadj,
+ xadj <- as.numeric(tcltk::tkcanvasx(can, 0))
+ yadj <- as.numeric(tcltk::tkcanvasy(can, 0))
+ hbox <- tcltk::tkcreate(can, "rectangle",
+ tcltk::tkbbox(can, "selected"),
+ outline = "red")
+ tcltk::tkaddtag(can, "box", "withtag", hbox)
+ conn <- tcltk::tkcreate(can, "line", .lastX + xadj, .lastY+yadj,
.pX, .pY, fill="red")
- tkaddtag(can, "ptr", "withtag", conn)
+ tcltk::tkaddtag(can, "ptr", "withtag", conn)
}
## Edit label
pEdit <- function() {
- tkdtag(can, "selected")
- tkaddtag(can, "selected", "withtag", "current")
- tkitemraise(can, "current")
- click <- tkfind(can, "withtag", "current")
- txt <- tclVar(labtext[[click]])
+ tcltk::tkdtag(can, "selected")
+ tcltk::tkaddtag(can, "selected", "withtag", "current")
+ tcltk::tkitemraise(can, "current")
+ click <- tcltk::tkfind(can, "withtag", "current")
+ txt <- tcltk::tclVar(labtext[[click]])
i <- as.numeric(id[[click]])
- tt <- tktoplevel()
- labEd <- tkentry(tt, width=20, textvariable=txt)
- tkgrid(tklabel(tt, text = "Edit label"))
- tkgrid(labEd, pady="5m", padx="5m")
+ tt <- tcltk::tktoplevel()
+ labEd <- tcltk::tkentry(tt, width=20, textvariable=txt)
+ tcltk::tkgrid(tcltk::tklabel(tt, text = "Edit label"))
+ tcltk::tkgrid(labEd, pady="5m", padx="5m")
isDone <- function() {
- txt <- tclvalue(txt)
- tkitemconfigure(can, click, text = txt)
+ txt <- tcltk::tclvalue(txt)
+ tcltk::tkitemconfigure(can, click, text = txt)
rownames(sco)[i] <<- txt
- tkdestroy(tt)
+ tcltk::tkdestroy(tt)
}
- tkbind(labEd, "", isDone)
+ tcltk::tkbind(labEd, "", isDone)
}
## Zooming: draw rectangle and take its user coordinates
## Rectangle: first corner
@@ -519,7 +525,7 @@
x <- as.numeric(x)
y <- as.numeric(y)
## yadj here and below adjusts for canvas scrolling
- yadj <- as.numeric(tkcanvasy(can, 0))
+ yadj <- as.numeric(tcltk::tkcanvasy(can, 0))
.pX <<- x
.pY <<- y + yadj
}
@@ -527,13 +533,13 @@
pRect <- function(x, y) {
x <- as.numeric(x)
y <- as.numeric(y)
- tkdelete(can, "box")
- yadj <- as.numeric(tkcanvasy(can, 0))
+ tcltk::tkdelete(can, "box")
+ yadj <- as.numeric(tcltk::tkcanvasy(can, 0))
.lastX <<- x
.lastY <<- y + yadj
- rect <- tkcreate(can, "rectangle", .pX, .pY, .lastX, .lastY,
+ rect <- tcltk::tkcreate(can, "rectangle", .pX, .pY, .lastX, .lastY,
outline="blue")
- tkaddtag(can, "box", "withtag", rect)
+ tcltk::tkaddtag(can, "box", "withtag", rect)
}
## Redraw ordiktplot with new xlim and ylim
pZoom <- function() {
@@ -555,20 +561,21 @@
.pY <- 0
## Mouse bindings:
## Moving a label
- tkitembind(can, "label", "", pEnter)
- tkitembind(can, "label", "", pLeave)
- tkitembind(can, "label", "<1>", pDown)
- tkitembind(can, "label", "",
- function() {tkdtag(can, "selected"); tkdelete(can, "ptr")})
- tkitembind(can, "label", "", pMove)
+ tcltk::tkitembind(can, "label", "", pEnter)
+ tcltk::tkitembind(can, "label", "", pLeave)
+ tcltk::tkitembind(can, "label", "<1>", pDown)
+ tcltk::tkitembind(can, "label", "",
+ function() {tcltk::tkdtag(can, "selected")
+ tcltk::tkdelete(can, "ptr")})
+ tcltk::tkitembind(can, "label", "", pMove)
## Edit labels
- tkitembind(can, "label", "", pEdit)
+ tcltk::tkitembind(can, "label", "", pEdit)
## Zoom (with one-button mouse)
- tkbind(can, "", pRect0)
- tkbind(can, "", pRect)
- tkbind(can, "", pZoom)
+ tcltk::tkbind(can, "", pRect0)
+ tcltk::tkbind(can, "", pRect)
+ tcltk::tkbind(can, "", pZoom)
## Zoom (with right button)
- tkbind(can, "", pRect0)
- tkbind(can, "", pRect)
- tkbind(can, "", pZoom)
+ tcltk::tkbind(can, "", pRect0)
+ tcltk::tkbind(can, "", pRect)
+ tcltk::tkbind(can, "", pZoom)
}
Modified: pkg/vegan/inst/NEWS.Rd
===================================================================
--- pkg/vegan/inst/NEWS.Rd 2014-11-24 10:44:01 UTC (rev 2913)
+++ pkg/vegan/inst/NEWS.Rd 2014-12-03 10:45:38 UTC (rev 2914)
@@ -2,6 +2,28 @@
\title{vegan News}
\encoding{UTF-8}
+\section{Changes in version 2.2-1}{
+
+ \subsection{BUG FIXES}{
+ \itemize{
+
+ \item \code{tolerance} function failed for unconstrained
+ correspondence analysis.
+
+ }
+ } % bug fixes
+
+ \subsection{NEW FEATURES}{
+ \itemize{
+
+ \item \code{linestack} accepts now expressions (such as
+ mathematical notation) as labels.
+
+ }
+ } % new features
+
+} % v2.2-1
+
\section{Changes in version 2.2-0}{
\subsection{GENERAL}{
From noreply at r-forge.r-project.org Wed Dec 3 11:45:39 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Wed, 3 Dec 2014 11:45:39 +0100 (CET)
Subject: [Vegan-commits] r2915 - pkg/vegan/inst
Message-ID: <20141203104539.C29821874EA@r-forge.r-project.org>
Author: jarioksa
Date: 2014-12-03 11:45:39 +0100 (Wed, 03 Dec 2014)
New Revision: 2915
Modified:
pkg/vegan/inst/NEWS.Rd
Log:
Merge branch 'cran-2.2' into r-forge-svn-local
Modified: pkg/vegan/inst/NEWS.Rd
===================================================================
--- pkg/vegan/inst/NEWS.Rd 2014-12-03 10:45:38 UTC (rev 2914)
+++ pkg/vegan/inst/NEWS.Rd 2014-12-03 10:45:39 UTC (rev 2915)
@@ -4,6 +4,16 @@
\section{Changes in version 2.2-1}{
+ \subsection{INSTALLATION}{
+ \itemize{
+
+ \item \pkg{vegan} can be installed and loaded without \pkg{tcltk}
+ package. The \pkg{tcltk} package is needed in \code{orditkplot}
+ function for interactive editing of ordination graphics.
+
+ }
+ }
+
\subsection{BUG FIXES}{
\itemize{
From noreply at r-forge.r-project.org Wed Dec 3 11:46:54 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Wed, 3 Dec 2014 11:46:54 +0100 (CET)
Subject: [Vegan-commits] r2916 - www
Message-ID: <20141203104654.E73B11874EA@r-forge.r-project.org>
Author: jarioksa
Date: 2014-12-03 11:46:54 +0100 (Wed, 03 Dec 2014)
New Revision: 2916
Modified:
www/NEWS.html
Log:
Update NEWS
Modified: www/NEWS.html
===================================================================
--- www/NEWS.html 2014-12-03 10:45:39 UTC (rev 2915)
+++ www/NEWS.html 2014-12-03 10:46:54 UTC (rev 2916)
@@ -7,6 +7,47 @@
vegan News
+
Changes in version 2.2-1
+
+
+
+
INSTALLATION
+
+
+
+
vegan can be installed and loaded without tcltk
+package. The tcltk package is needed in orditkplot
+function for interactive editing of ordination graphics.
+
+
+
+
+
+
+
BUG FIXES
+
+
+
+
tolerance function failed for unconstrained
+correspondence analysis.
+
+
+
+
+
+
+
NEW FEATURES
+
+
+
+
linestack accepts now expressions (such as
+mathematical notation) as labels.
+
+
+
+
+
+
Changes in version 2.2-0
From noreply at r-forge.r-project.org Mon Dec 8 09:47:24 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Mon, 8 Dec 2014 09:47:24 +0100 (CET)
Subject: [Vegan-commits] r2917 - pkg/vegan/R
Message-ID: <20141208084724.4CDCD1873ED@r-forge.r-project.org>
Author: jarioksa
Date: 2014-12-08 09:47:23 +0100 (Mon, 08 Dec 2014)
New Revision: 2917
Modified:
pkg/vegan/R/as.hclust.spantree.R
pkg/vegan/R/cophenetic.spantree.R
pkg/vegan/R/lines.spantree.R
pkg/vegan/R/plot.spantree.R
pkg/vegan/R/spantree.R
Log:
Handle degenerate spantrees with two, one or zero points
(cherry picked from commit 8bc11fa94ca5ab17e007aaec30507505e377847c)
Modified: pkg/vegan/R/as.hclust.spantree.R
===================================================================
--- pkg/vegan/R/as.hclust.spantree.R 2014-12-03 10:46:54 UTC (rev 2916)
+++ pkg/vegan/R/as.hclust.spantree.R 2014-12-08 08:47:23 UTC (rev 2917)
@@ -12,7 +12,9 @@
{
## Order by the lengths of spanning tree links
o <- order(x$dist)
- npoints <- length(o) + 1
+ npoints <- x$n
+ if(npoints < 2)
+ stop("needs at least two points")
## Ordered indices of dads and kids
dad <- (2:npoints)[o]
kid <- x$kid[o]
Modified: pkg/vegan/R/cophenetic.spantree.R
===================================================================
--- pkg/vegan/R/cophenetic.spantree.R 2014-12-03 10:46:54 UTC (rev 2916)
+++ pkg/vegan/R/cophenetic.spantree.R 2014-12-08 08:47:23 UTC (rev 2917)
@@ -1,8 +1,10 @@
-"cophenetic.spantree" <-
+`cophenetic.spantree` <-
function(x)
{
- n <- length(x$kid) + 1
+ n <- x$n
mat <- matrix(NA, nrow=n, ncol=n)
+ if (n < 2)
+ return(as.dist(mat))
ind <- apply(cbind(2:n, x$kid), 1, sort)
ind <- t(ind[2:1,])
mat[ind] <- x$dist
Modified: pkg/vegan/R/lines.spantree.R
===================================================================
--- pkg/vegan/R/lines.spantree.R 2014-12-03 10:46:54 UTC (rev 2916)
+++ pkg/vegan/R/lines.spantree.R 2014-12-08 08:47:23 UTC (rev 2917)
@@ -1,9 +1,10 @@
-"lines.spantree" <-
+`lines.spantree` <-
function (x, ord, display = "sites", ...)
{
ord <- scores(ord, display = display, ...)
tree <- x$kid
- ordiArgAbsorber(ord[-1, 1], ord[-1, 2], ord[tree, 1], ord[tree, 2],
- FUN = segments, ...)
+ if (x$n > 1)
+ ordiArgAbsorber(ord[-1, 1], ord[-1, 2], ord[tree, 1], ord[tree, 2],
+ FUN = segments, ...)
invisible()
}
Modified: pkg/vegan/R/plot.spantree.R
===================================================================
--- pkg/vegan/R/plot.spantree.R 2014-12-03 10:46:54 UTC (rev 2916)
+++ pkg/vegan/R/plot.spantree.R 2014-12-08 08:47:23 UTC (rev 2917)
@@ -1,21 +1,24 @@
-"plot.spantree" <-
+`plot.spantree` <-
function (x, ord, cex = 0.7, type = "p", labels, dlim, FUN = sammon,
...)
{
FUNname <- deparse(substitute(FUN))
FUN <- match.fun(FUN)
- n <- length(x$kid) + 1
+ n <- x$n
if (missing(ord)) {
d <- cophenetic(x)
if (any(d<=0))
d[d<=0] <- min(d>0)/10
if (!missing(dlim))
d[d > dlim ] <- dlim
- y <- cmdscale(d)
- dup <- duplicated(y)
- if (any(dup))
- y[dup, ] <- y[dup,] + runif(2*sum(dup), -0.01, 0.01)
- ord <- FUN(d, y)
+ if (n > 2) {
+ y <- cmdscale(d)
+ dup <- duplicated(y)
+ if (any(dup))
+ y[dup, ] <- y[dup,] + runif(2*sum(dup), -0.01, 0.01)
+ ord <- FUN(d, y)
+ } else
+ ord <- cbind(seq_len(n), rep(0,n))
}
ord <- scores(ord, display = "sites", ...)
ordiArgAbsorber(ord, asp = 1, type = "n", FUN = "plot", ...)
Modified: pkg/vegan/R/spantree.R
===================================================================
--- pkg/vegan/R/spantree.R 2014-12-03 10:46:54 UTC (rev 2916)
+++ pkg/vegan/R/spantree.R 2014-12-08 08:47:23 UTC (rev 2917)
@@ -1,4 +1,4 @@
-"spantree" <-
+`spantree` <-
function (d, toolong = 0)
{
dis <- as.dist(d)
@@ -8,7 +8,7 @@
n = as.integer(n), val = double(n + 1),
dad = integer(n + 1), NAOK = TRUE, PACKAGE = "vegan")
out <- list(kid = dis$dad[2:n] + 1, dist = dis$val[2:n],
- labels = labels, call = match.call())
+ labels = labels, n = n, call = match.call())
class(out) <- "spantree"
out
}
From noreply at r-forge.r-project.org Fri Dec 12 09:42:59 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Fri, 12 Dec 2014 09:42:59 +0100 (CET)
Subject: [Vegan-commits] r2918 - in pkg/vegan: R vignettes
Message-ID: <20141212084259.42D0D1862D4@r-forge.r-project.org>
Author: jarioksa
Date: 2014-12-12 09:42:58 +0100 (Fri, 12 Dec 2014)
New Revision: 2918
Modified:
pkg/vegan/R/estimateR.default.R
pkg/vegan/R/specpool.R
pkg/vegan/vignettes/diversity-vegan.Rnw
pkg/vegan/vignettes/vegan.bib
Log:
Squashed commit of the following:
commit fd3ffc60c65f46f1c5554025ece18f2fd58cfda1
Author: Jari Oksanen
Date: Thu Dec 11 12:51:19 2014 +0200
tweaks
(cherry picked from commit 685e5795e02deb75c78803f2f1c2e82ef3c49663)
commit 66aca05f78de8dadb0cc7c9e978da59794726dd9
Author: Jari Oksanen
Date: Wed Dec 10 20:30:30 2014 +0200
Edit diversity-vegan
(cherry picked from commit 79eb46ece1cac5081f50d4bd84b0c4e8899b2b1c)
commit 2bc1a16c03f11d8886f4ed57ad391e7a5d851e32
Author: Jari Oksanen
Date: Sun Dec 7 19:04:14 2014 +0200
Edit diversity-vegan vignette
Be explicit about extended species richness only concerning
the number of unseen species and not the total number of species.
(cherry picked from commit b06ec8328d3083804d2a84ad4b74b67cab41d428)
commit ee9153e2ce44b179eb118611c0e6989e8bdd56bf
Author: Jari Oksanen
Date: Sun Dec 7 18:14:20 2014 +0200
Use only the new "exact" variance estimator for Chao bias-reduced
(cherry picked from commit 9e49c56035bd0ac91b4bd23f2900d57ba4361ff9)
commit 39f7e67a1c30ff84a6dd6263df950d2e7cbe075e
Author: Jari Oksanen
Date: Sun Dec 7 18:06:39 2014 +0200
Document the exact Chao bia-corrected variance estimator
(cherry picked from commit d8253316fc983d4d0ba5a2910a0079b8cffd8852)
commit b150c979190a9288d2aca2291aa50308dee40324
Author: Jari Oksanen
Date: Sun Dec 7 16:50:53 2014 +0200
More exact derivation of approximate variance of bias-reduced Chao
The common texts (and EstimateS web page) use approximate estimator
for bias-corrected Chao estimate. This uses derivation for the basic
estimator but replaces terms with those of bias corrected form
(a1^2 -> a1*(a1-1), 2*a2 -> 2*(a2+1)). The used form is unpublished
as such, but it follows exactly the derivation as given in Chiu et al.,
web appendix. The numerical differences between forms are tiny: in
BCI the maximum difference is ca. 0.02%, and in the 'mite' data up to
12% -- it seems that difference vanishes as the sample size (no. of
individuals) increases.
(cherry picked from commit b7f92c6fb41288c3e441e14acc044bb0ce748e26)
commit e2332b369d9b7df79545819406336db3662202b7
Author: Jari Oksanen
Date: Thu Dec 4 20:28:49 2014 +0200
Formatting of diversity vignette
(cherry picked from commit d24db8b233328d961ea77c65e46f9531b5ee418e)
commit 1ed473db86678e0070de068dbe3324952386589d
Author: Jari Oksanen
Date: Thu Dec 4 17:14:40 2014 +0200
Edit description of Chao estimates in the diversity vignette
(cherry picked from commit d689ed87db134f5da95c24485a2f54e4847b7703)
commit 0b6e8af9c070084fba41e99c0578293e3f42de45
Author: Jari Oksanen
Date: Thu Dec 4 13:11:29 2014 +0200
Use simpler expression for the variance of Chao extrapolation
The new expression uses lower power or one multiplication less than
the old one. The old one directly lifted from the literature, and
it is mathematically equal to the new one.
(cherry picked from commit 92db96cb09a3191add7464220777ca9cfcf97e27)
commit 3aef904857191eb6f69d840adb57254ff7c82253
Author: Jari Oksanen
Date: Mon Dec 8 12:39:35 2014 +0200
typo reported by Olivier Missa at ens.fr
(cherry picked from commit 199131ed12c5c514223f8681121eabf6e516a6b2)
Modified: pkg/vegan/R/estimateR.default.R
===================================================================
--- pkg/vegan/R/estimateR.default.R 2014-12-08 08:47:23 UTC (rev 2917)
+++ pkg/vegan/R/estimateR.default.R 2014-12-12 08:42:58 UTC (rev 2918)
@@ -55,15 +55,26 @@
##else
## S.Chao1 <- S.obs
Deriv.Ch1 <- gradF(a, i)
- ##if (a[2] > 0)
- ## sd.Chao1 <- sqrt(a[2] * (SSC * (SSC * (G^4/4 + G^3) + G^2/2)))
- ##else if (a[1] > 0)
- sd.Chao1 <-
- sqrt(SSC*(a[1]*(a[1]-1)/2/(a[2]+1) +
- SSC*(a[1]*(2*a[1]-1)^2/4/(a[2]+1)^2 +
- a[1]^2*a[2]*(a[1]-1)^2/4/(a[2]+1)^4)))
- ##else
- ## sd.Chao1 <- 0
+
+ ## The commonly used variance estimator is wrong for bias-reduced
+ ## Chao estimate. It is based on the variance estimator of basic
+ ## Chao estimate, but replaces the basic terms with corresponding
+ ## terms in the bias-reduced estimate. The following is directly
+ ## derived from the bias-reduced estimate.
+
+ ## The commonly used one (for instance, in EstimateS):
+ ##sd.Chao1 <-
+ ## sqrt(SSC*(a[1]*(a[1]-1)/2/(a[2]+1) +
+ ## SSC*(a[1]*(2*a[1]-1)^2/4/(a[2]+1)^2 +
+ ## a[1]^2*a[2]*(a[1]-1)^2/4/(a[2]+1)^4)))
+
+ sd.Chao1 <- (a[1]*((-a[2]^2+(-2*a[2]-a[1])*a[1])*a[1] +
+ (-1+(-4+(-5-2*a[2])*a[2])*a[2] +
+ (-2+(-1+(2*a[2]+2)*a[2])*a[2] +
+ (4+(6+4*a[2])*a[2] + a[1]*a[2])*a[1])*a[1])*S.Chao1))/
+ 4/(a[2]+1)^4/S.Chao1
+ sd.Chao1 <- sqrt(sd.Chao1)
+
C.ace <- 1 - a[1]/N.rare
i <- 1:length(a)
thing <- i * (i - 1) * a
@@ -72,7 +83,7 @@
S.ACE <- S.abund + S.rare/C.ace + max(Gam, 0) * a[1]/C.ace
sd.ACE <- sqrt(sum(Deriv.Ch1 %*% t(Deriv.Ch1) * (diag(a) -
a %*% t(a)/S.ACE)))
- out <- list(S.obs = S.obs, S.chao1 = S.Chao1, se.chao1 = sd.Chao1,
+ out <- list(S.obs = S.obs, S.chao1 = S.Chao1, se.chao1 = sd.Chao1,
S.ACE = S.ACE, se.ACE = sd.ACE)
out <- unlist(out)
out
Modified: pkg/vegan/R/specpool.R
===================================================================
--- pkg/vegan/R/specpool.R 2014-12-08 08:47:23 UTC (rev 2917)
+++ pkg/vegan/R/specpool.R 2014-12-12 08:42:58 UTC (rev 2918)
@@ -52,7 +52,7 @@
a1/a2
else 0
if (a2 > 0)
- var.chao[is] <- a2 * ssc * (0.5 + ssc * (1 + aa/4) * aa) * aa * aa
+ var.chao[is] <- a1 * ssc * (0.5 + ssc * (1 + aa/4) * aa) * aa
else
var.chao[is] <-
ssc * (ssc * (a1*(2*a1-1)^2/4 - a1^4/chao[is]/4) + a1*(a1-1)/2)
Modified: pkg/vegan/vignettes/diversity-vegan.Rnw
===================================================================
--- pkg/vegan/vignettes/diversity-vegan.Rnw 2014-12-08 08:47:23 UTC (rev 2917)
+++ pkg/vegan/vignettes/diversity-vegan.Rnw 2014-12-12 08:42:58 UTC (rev 2918)
@@ -103,8 +103,8 @@
\begin{equation}
H_q = \frac{1}{q-1} \left(1 - \sum_{i=1}^S p^q \right) \, .
\end{equation}
-This corresponds to common diversity indices: $H_0 = S-1$, $H_1 = H'$,
-and $H_2 = D_2$, and can be converted to the Hill number:
+These correspond to common diversity indices: $H_0 = S-1$, $H_1 = H'$,
+and $H_2 = D_1$, and can be converted to Hill numbers:
\begin{equation}
N_q = (1 - (q-1) H_q )^\frac{1}{1-q} \, .
\end{equation}
@@ -572,66 +572,90 @@
species is related to the number of rare species, or species seen only
once or twice.
+The incidence-based functions group species by their number of
+occurrences $f_i = f_0, f_1, \ldots, f_N$, where $f$ is the number of
+species occuring in exactly $i$ sites in the data: $f_N$ is the number
+of species occurring on every $N$ site, $f_1$ the number of species
+occurring once, and $f_0$ the number of species in the species pool
+but not found in the sample. The total number of species in the pool
+$S_p$ is
+\begin{equation}
+S_p = \sum_{i=0}^N f_i = f_0+ S_o \,,
+\end{equation}
+where $S_o = \sum_{i>0} f_i$ is the observed number of species. The
+sampling proportion $i/N$ is an estimate for the commonness of the
+species in the community. When species is present in the community but
+not in the sample, $i=0$ is an obvious under-estimate, and
+consequently, for values $i>0$ the species commonness is
+over-estimated \citep{Good53}. The models for the pool size estimate
+the number of species missing in the sample $f_0$.
+
Function \code{specpool} implements the following models to estimate
-the pool size $S_p$ \citep{SmithVanBelle84, Chao87, ChiuEtal14}:
+the number of missing species $f_0$. Chao estimator is \citep{Chao87, ChiuEtal14}:
+\begin{equation}
+\label{eq:chao}
+\hat f_0 = \begin{cases}
+ \frac{f_1^2}{2 f_2} \frac{N-1}{N} &\text{if } f_2 > 0 \\
+\frac{f_1 (f_1 -1)}{2} \frac{N-1}{N} & \text{if } f_2 = 0
+\end{cases}
+\end{equation}
+The latter case for $f_2=0$ is known as the bias-corrected
+form. \citet{ChiuEtal14} introduced the small-sample correction term
+$\frac{N}{N-1}$, but it was not originally used \citep{Chao87}.
+
+The first and second order jackknife estimators are
+\citep{SmithVanBelle84}:
\begin{align}
-\label{eq:chao-basic}
-S_p &= S_o + \frac{f_1^2}{2 f_2} \frac{N-1}{N} & \text{Chao}\\
-\label{eq:chao-bc}
-S_p &= S_o + \frac{f_1 (f_1 -1)}{2 (f_2+1)} \frac{N-1}{N} & \text{Chao bias-corrected}\\
-S_p &= S_o + f_1 \frac{N-1}{N} & \text{1st order Jackknife}\\
-S_p & = S_o + f_1 \frac{2N-3}{N} \nonumber \\ & + f_2 \frac{(N-2)^2}{N(N-1)}
-& \text{2nd order Jackknife}\\
-S_p &= S_o + \sum_{i=1}^{S_o} (1-p_i)^N & \text{Bootstrap}
+\hat f_0 &= f_1 \frac{N-1}{N} \\
+\hat f_0 & = f_1 \frac{2N-3}{N} + f_2 \frac{(N-2)^2}{N(N-1)}
\end{align}
-Here $S_o$ is the observed number of species, $f_1$ and $f_2$ are the
-numbers of species observed once or twice, $N$ is the number of sites,
-and $p_i$ are proportions of species. The idea in jackknife seems to
-be that we missed about as many species as we saw only once, and the
-idea in bootstrap that if we repeat sampling (with replacement) from
-the same data, we miss as many species as we missed originally.
-\citet{ChiuEtal14} introduced the small-sample correction term
-$\frac{N}{N-1}$, but it was not originally used \citep{Chao87}.
+The boostrap estimator is \citep{SmithVanBelle84}:
+\begin{equation}
+\hat f_0 = \sum_{i=1}^{S_o} (1-p_i)^N
+\end{equation}
+The idea in jackknife seems to be that we missed about as many species
+as we saw only once, and the idea in bootstrap that if we repeat
+sampling (with replacement) from the same data, we miss as many
+species as we missed originally.
-The variance the estimator of the basic Chao estimate is \citep{ChiuEtal14}:
+The variance estimaters only concern the estimated number of missing
+species $\hat f_0$, although they are often expressed as they would
+apply to the pool size $S_p$; this is only true if we assume that
+$\VAR(S_o) = 0$. The variance of the Chao estimate is \citep{ChiuEtal14}:
\begin{multline}
\label{eq:var-chao-basic}
-s^2 = f_2 \left(A^2 \frac{G^4}{4} + A^2 G^3 + A \frac{G^2}{2} \right),\\
+\VAR(\hat f_0) = f_1 \left(A^2 \frac{G^3}{4} + A^2 G^2 + A \frac{G}{2} \right),\\
\text{where}\; A = \frac{N-1}{N}\;\text{and}\; G = \frac{f_1}{f_2}
\end{multline}
-The variance of bias-corrected Chao estimate can be approximated by
-replacing the terms of eq.~\ref{eq:var-chao-basic} with the
-corresponding terms in eq.~\ref{eq:chao-bc}:
-\begin{multline}
-\label{eq:var-chao-bc}
-s^2 = A \frac{f_1(f_1-1)}{2(f_2+1)} + A^2 \frac{f_1(2 f_1+1)^2}{(f_2+1)^2}\\
- + A^2 \frac{f_1^2 f_2 (f_1 -1)^2}{4 (f_2 + 1)^4}
-\end{multline}
-If we apply the bias-correction in the special case where there are no
-doubletons ($f_2 = 0$), the he variance is
+%% The variance of bias-corrected Chao estimate can be approximated by
+%% replacing the terms of eq.~\ref{eq:var-chao-basic} with the
+%% corresponding terms of the bias-correcter form of in eq.~\ref{eq:chao}:
+%% \begin{multline}
+%% \label{eq:var-chao-bc}
+%% s^2 = A \frac{f_1(f_1-1)}{2} + A^2 \frac{f_1(2 f_1+1)^2}{(f_2+1)^2}\\
+%% + A^2 \frac{f_1^2 f_2 (f_1 -1)^2}{4 (f_2 + 1)^4}
+%% \end{multline}
+For the bias-corrected form of eq.~\ref{eq:chao} (case $f_2 = 0$), the he variance is
\citep[who omit small-sample correction in some terms]{ChiuEtal14}:
\begin{multline}
\label{eq:var-chao-bc0}
-s^2 = \frac{1}{4} A^2 f_1 (2f_1 -1)^2 + \frac{1}{2} A f_1 (f_1-1) - \frac{1}{4}A^2 \frac{f_1^4}{S_p}
+\VAR(\hat f_0) = \frac{1}{4} A^2 f_1 (2f_1 -1)^2 + \frac{1}{2} A f_1 (f_1-1) - \frac{1}{4}A^2 \frac{f_1^4}{S_p}
\end{multline}
-Function \code{specpool} uses eq.~\ref{eq:chao-basic} and estimates
-its variance with eq.~\ref{eq:var-chao-basic} when $f_2 > 0$. When
-$f_2 = 0$, \code{specpool} applies eq.~\ref{eq:chao-bc} which reduces
-to $\frac{N-1}{N} \frac{1}{2} f_1 (f_1 - 1)$, and its variance
-estimator eq.~\ref{eq:var-chao-bc0}.
The variance of the first-order jackknife is based on the number of
``singletons'' $r$ (species occurring only once in the data) in sample
plots \citep{SmithVanBelle84}:
\begin{equation}
-s^2 = \left(\sum_{i=1}^N r_i^2 - \frac{f_1}{N}\right) \frac{N-1}{N}
+\VAR(\hat f_0) = \left(\sum_{i=1}^N r_i^2 - \frac{f_1}{N}\right) \frac{N-1}{N}
\end{equation}
Variance of the second-order jackknife is not evaluated in
\code{specpool} (but contributions are welcome).
-For the variance of bootstrap estimator, it is practical to define a
-new variable $q_i = (1-p_i)^N$ for each species \citep{SmithVanBelle84}:
+
+The variance of bootstrap estimator is\citep{SmithVanBelle84}:
\begin{multline}
-s^2 = \sum_{i=1}^{S_o} q_i (1-q_i) \\ +2 \sum_{i \neq j}^{S_o} \left[(Z_{ij}/N)^N - q_i q_j \right]
+\VAR(\hat f_0) = \sum_{i=1}^{S_o} q_i (1-q_i) \\ +2 \sum_{i \neq
+ j}^{S_o} \left[(Z_{ij}/N)^N - q_i q_j \right] \\
+\text{where } q_i = (1-p_i)^N \, ,
\end{multline}
where $Z_{ij}$ is the number of sites where both species are absent.
@@ -658,12 +682,40 @@
<<>>=
estimateR(BCI[k,])
@
+In abundance based models $a_i$ denotes the number of species with $i$
+individuals, and takes the place of $f_i$ of previous models.
Chao's method is similar as the bias-corrected model
-eq.~\ref{eq:chao-bc} with its variance estimator
-eq.~\ref{eq:var-chao-bc}, but it uses counts of individuals instead of
-incidences, and does not use small sample correction. \textsc{ace} is
-based on rare species also:
+eq.~\ref{eq:chao} \citep{Chao87, ChiuEtal14}:
\begin{equation}
+ \label{eq:chao-bc}
+ S_p = S_o + \frac{a_1 (a_1 - 1)}{2 (a_2 + 1)}\,.
+\end{equation}
+When $f_2=0$, eq.~\ref{eq:chao-bc} reduces to the bias-corrected form
+of eq.~\ref{eq:chao}, but quantitative estimators are based on
+abundances and do not use small-sample correction. This is not usually
+needed because sample sizes are total numbers of individuals, and
+these are usually high, unlike in frequency based models, where the
+sample size is the number of sites \citep{ChiuEtal14}.
+
+A commonly used approximate variance estimator of eq.~\ref{eq:chao-bc} is:
+\begin{multline}
+ \label{eq:var-chao-bc}
+ s^2 = \frac{a_1(a_1-1)}{2} + \frac{a_1(2 a_1+1)^2}{(a_2+1)^2}\\
+ + \frac{a_1^2 a_2 (a_1 -1)^2}{4 (a_2 + 1)^4}
+\end{multline}
+However, \pkg{vegan} does not use this, but instead the following more
+exact form which was directly derived from eq.~\ref{eq:chao-bc}
+following \citet[web appendix]{ChiuEtal14}:
+\begin{multline}
+ s^2 = \frac{1}{4} \frac{1}{(a_2+1)^4 S_p} [a_1 (S_p a_1^3
+ a_2 + 4 S_p a_1^2 a_2^2 \\+ 2 S_p a_1 a_2^3 + 6 S_p a_1^2 a_2 + 2 S_p
+ a_1 a_2^2 -2 S_p a_2^3 \\+ 4 S_p a_1^2 + S_p a_1 a_2 -5 S_p a_2^2 - a_1^3 - 2
+ a_1^2 a_2\\ - a_1 a_2^2 - 2 S_p a_1 - 4 S_p a_2 - S_p ) ]\,.
+\end{multline}
+The variance estimators only concern the number of unseen species like previously.
+
+The \textsc{ace} is estimator is defined as \citep{OHara05}:
+\begin{equation}
\begin{split}
S_p &= S_\mathrm{abund} + \frac{S_\mathrm{rare}}{C_\mathrm{ACE}} +
\frac{a_1}{C_\mathrm{ACE}} \gamma^2\, , \quad \text{where}\\
@@ -677,7 +729,9 @@
Here $S_\mathrm{abund}$ and $S_\mathrm{rare}$ are the numbers of
species of abundant and rare species, with an arbitrary upper limit of
10 individuals for a rare species, and $N_\mathrm{rare}$ is the total
-number of individuals in rare species.
+number of individuals in rare species. The variance estimator uses
+iterative solution, and it is best interpreted from the source code or
+following \citet{OHara05}.
The pool size
is estimated separately for each site, but if input is a data frame,
Modified: pkg/vegan/vignettes/vegan.bib
===================================================================
--- pkg/vegan/vignettes/vegan.bib 2014-12-08 08:47:23 UTC (rev 2917)
+++ pkg/vegan/vignettes/vegan.bib 2014-12-12 08:42:58 UTC (rev 2918)
@@ -1,4 +1,22 @@
+ at Article{OHara05,
+ author = {R. B. O'Hara},
+ title = {Species richness estimators: how many species can
+ dance on the head of a pin},
+ journal = {Journal of Animal Ecology},
+ year = 2005,
+ volume = 74,
+ pages = {375--386}}
+
+ at Article{Good53,
+ author = {I. J. Good},
+ title = {The population frequencies of species and the
+ estimation of population parameters},
+ journal = {Biometrika},
+ year = 1953,
+ volume = 40,
+ pages = {237--264}}
+
@Article{ChiuEtal14,
author = {C. H. Chiu and Y. T. Wang and B. A. Walther and
A. Chao},
From noreply at r-forge.r-project.org Fri Dec 12 09:59:36 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Fri, 12 Dec 2014 09:59:36 +0100 (CET)
Subject: [Vegan-commits] r2919 - pkg/vegan/inst
Message-ID: <20141212085936.A0FA5187874@r-forge.r-project.org>
Author: jarioksa
Date: 2014-12-12 09:59:36 +0100 (Fri, 12 Dec 2014)
New Revision: 2919
Modified:
pkg/vegan/inst/NEWS.Rd
Log:
NEWS about new variance estimator for Chao in estimateR
Modified: pkg/vegan/inst/NEWS.Rd
===================================================================
--- pkg/vegan/inst/NEWS.Rd 2014-12-12 08:42:58 UTC (rev 2918)
+++ pkg/vegan/inst/NEWS.Rd 2014-12-12 08:59:36 UTC (rev 2919)
@@ -26,9 +26,18 @@
\subsection{NEW FEATURES}{
\itemize{
- \item \code{linestack} accepts now expressions (such as
- mathematical notation) as labels.
+ \item \code{estimateR} uses a more exact variance formula for
+ bias-corrected Chao estimate of extrapolated number of
+ species. The new formula may be unpublished, but it was derived
+ following the guidelines of Chiu, Wang, Walther & Chao,
+ \emph{Biometrics} 70, 671--682 (2014),
+ \href{http://onlinelibrary.wiley.com/doi/10.1111/biom.12200/suppinfo}{online
+ supplementary material}.
+ \item \code{linestack} accepts now expressions as labels. This
+ allows using mathematical symbols and formula given as
+ mathematical expressions.
+
}
} % new features
From noreply at r-forge.r-project.org Fri Dec 12 10:01:27 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Fri, 12 Dec 2014 10:01:27 +0100 (CET)
Subject: [Vegan-commits] r2920 - www
Message-ID: <20141212090127.F260318787A@r-forge.r-project.org>
Author: jarioksa
Date: 2014-12-12 10:01:27 +0100 (Fri, 12 Dec 2014)
New Revision: 2920
Modified:
www/NEWS.html
Log:
update NEWS.html
Modified: www/NEWS.html
===================================================================
--- www/NEWS.html 2014-12-12 08:59:36 UTC (rev 2919)
+++ www/NEWS.html 2014-12-12 09:01:27 UTC (rev 2920)
@@ -1,9 +1,10 @@
-R: vegan News
-
-
+
+R: vegan News
+
+
-
NEWS
R Documentation
+
NEWS
R Documentation
vegan News
@@ -40,9 +41,19 @@
-
linestack accepts now expressions (such as
-mathematical notation) as labels.
+
estimateR uses a more exact variance formula for
+bias-corrected Chao estimate of extrapolated number of
+species. The new formula may be unpublished, but it was derived
+following the guidelines of Chiu, Wang, Walther & Chao,
+Biometrics 70, 671–682 (2014),
+online
+supplementary material.
+
+
linestack accepts now expressions as labels. This
+allows using mathematical symbols and formula given as
+mathematical expressions.
+
@@ -69,7 +80,7 @@
be used both in Windows and in unix-alikes. Vegan vignette
on Design decision explains the implementation (use
vegandocs("decission"), and parallel package has more
-extensive documentation on parallel processing in R.
+extensive documentation on parallel processing in R.
The following function use parallel processing in analysing
permutation statistics: adonis, anosim,
@@ -132,7 +143,7 @@
vegan package dependencies and namespace imports
-were adapted to changes in R, and no more trigger warnings and
+were adapted to changes in R, and no more trigger warnings and
notes in package tests.
@@ -151,7 +162,7 @@
Function dispweight implements dispersion weighting
-of Clarke et al. (Marine Ecology Progress Series, 320,
+of Clarke et al. (Marine Ecology Progress Series, 320,
11–27). In addition, we implemented a new method for
generalized dispersion weighting gdispweight. Both
methods downweight species that are significantly
@@ -161,7 +172,7 @@
New hclust support functions reorder,
rev and scores. Functions reorder and
rev are similar as these functions for dendrogram
-objects in base R. However, reorder can use (and defaults
+objects in base R. However, reorder can use (and defaults
to) weighted mean. In weighted mean the node average is always the
mean of member leaves, whereas the dendrogram uses always
unweighted means of joined branches.
@@ -177,7 +188,7 @@
Function permustats extracts and inspects permutation
results with support functions summary, density,
densityplot, qqnorm and qqmath. The
-density and qqnorm are standard R tools that only
+density and qqnorm are standard R tools that only
work with one statistic, and densityplot and qqmath
are lattice graphics that work with univariate and
multivariate statistics. The results of following functions can be
@@ -298,7 +309,7 @@
Functions for extrapolated number of species or for the size
of species pool using Chao method were modified following Chiu et
-al., Biometrics 70, 671–682 (2014).
+al., Biometrics 70, 671–682 (2014).
Incidence based specpool can now use (and defaults to)
small sample correction with number of sites as the sample
@@ -342,7 +353,7 @@
III. varespec and dune use 8-character names (4
from genus + 4 from species epithet). New data set on
phylogenetic distances for dune was extracted from Zanne
-et al. (Nature 506, 89–92; 2014).
+et al. (Nature 506, 89–92; 2014).
User configurable plots for rarecurve.
@@ -474,11 +485,11 @@
This version is released due to changes in programming
-interface and testing procedures in R 3.0.2. If you are using an
-older version of R, there is no need to upgrade vegan. There
+interface and testing procedures in R 3.0.2. If you are using an
+older version of R, there is no need to upgrade vegan. There
are no new features nor bug fixes. The only user-visible changes
are in documentation and in output messages and formatting. Because
-of R changes, this version is dependent on R version 2.14.0
+of R changes, this version is dependent on R version 2.14.0
or newer and on lattice package.
@@ -494,7 +505,7 @@
This is a maintenance release that fixes some issues
-raised by changed in R toolset for processing vignettes. In
+raised by changed in R toolset for processing vignettes. In
the same we also fix some typographic issues in the vignettes.
@@ -540,7 +551,7 @@
tabasco() is a new function for graphical display
-of community data matrix. Technically it is an interface to R
+of community data matrix. Technically it is an interface to Rheatmap, but its use is closer to vegan function
vegemite. The function can reorder the community data
matrix similarly as vegemite, for instance, by ordination
@@ -729,7 +740,7 @@
plot etc. of the results. These methods are only used if
the full wcmdscale result is returned with, e.g., argument
eig = TRUE. The default is still to return only a matrix of
-scores similarly as the standard R function cmdscale(),
+scores similarly as the standard R function cmdscale(),
and in that case the new methods are not used.
@@ -828,13 +839,13 @@
version of LaTeX (TeXLive 2012).
-
R versions later than 2.15-1 (including development
+
R versions later than 2.15-1 (including development
version) report warnings and errors when installing and checking
vegan, and you must upgrade vegan to this version.
The warnings concern functions cIndexKM and
betadisper, and the error occurs in betadisper.
These errors and warnings were triggered by internal changes in
-R.
+R.
@@ -965,8 +976,8 @@
Added new nestedness functions nestedbetasor and
nestedbetajac that implement multiple-site dissimilarity
indices and their decomposition into turnover and nestedness
-components following Baselga (Global Ecology and
-Biogeography 19, 134–143; 2010).
+components following Baselga (Global Ecology and
+Biogeography 19, 134–143; 2010).
Added function rarecurve to draw rarefaction curves
@@ -976,8 +987,8 @@
Added function simper that implements
-“similarity percentages” of Clarke (Australian
-Journal of Ecology 18, 117–143; 1993). The method compares
+“similarity percentages” of Clarke (Australian
+Journal of Ecology 18, 117–143; 1993). The method compares
two or more groups and decomposes the average between-group
Bray-Curtis dissimilarity index to contributions by individual
species. The code was developed in
@@ -1049,8 +1060,8 @@
Added Cao dissimilarity (CYd) as a new dissimilarity
-method in vegdist following Cao et al., Water
-Envir Res 69, 95–106 (1997). The index should be good for
+method in vegdist following Cao et al., Water
+Envir Res 69, 95–106 (1997). The index should be good for
data with high beta diversity and variable sampling
intensity. Thanks to consultation to Yong Cao (Univ Illinois,
USA).
@@ -1129,7 +1140,7 @@
clamtest: new function to classify species as
generalists and specialists in two distinct habitats (CLAM test of
-Chazdon et al., Ecology 92, 1332–1343; 2011). The test is
+Chazdon et al., Ecology 92, 1332–1343; 2011). The test is
based on multinomial distribution of individuals in two habitat
types or sampling units, and it is applicable only to count data
with no over-dispersion.
@@ -1149,7 +1160,7 @@
vegdist, but that uses equal sampling probabilities for
species and analytic equations. The new raupcrick
function uses simulation with oecosimu. The function
-follows Chase et al. (2011) Ecosphere 2:art24
+follows Chase et al. (2011) Ecosphere 2:art24
[doi:10.1890/ES10-00117.1],
and was developed with the consultation of Brian Inouye.
@@ -1182,12 +1193,12 @@
updated because of a ‘NAMESPACE’ issue.
-
R 2.14.0 changed so that it does not accept using
+
R 2.14.0 changed so that it does not accept using
sd() function for matrices (which was the behaviour at
-least since R 1.0-0), and several vegan functions were
+least since R 1.0-0), and several vegan functions were
changed to adapt to this change (rda, capscale,
simulate methods for rda, cca and
-capscale). The change in R 2.14.0 does not influence the
+capscale). The change in R 2.14.0 does not influence the
results but you probably wish to upgrade vegan to avoid
annoying warnings.
@@ -1221,11 +1232,11 @@
Peter Minchin joins the vegan team.
-
vegan implements standard R ‘NAMESPACE’. In
+
vegan implements standard R ‘NAMESPACE’. In
general, S3 methods are not exported which means that you
cannot directly use or see contents of functions like
cca.default, plot.cca or anova.ccabyterm. To
-use these functions you should rely on R delegation and simply
+use these functions you should rely on R delegation and simply
use cca and for its result objects use plot and
anova without suffix .cca. To see the contents of
the function you can use :::, such as
@@ -1272,7 +1283,7 @@
eventstar finds the minimum of the evenness profile
on the Tsallis entropy, and uses this to find the corresponding
values of diversity, evenness and numbers equivalent following
-Mendes et al. (Ecography 31, 450-456; 2008). The code was
+Mendes et al. (Ecography 31, 450-456; 2008). The code was
contributed by Eduardo Ribeira Cunha and Heloisa Beatriz Antoniazi
Evangelista and adapted to vegan by Peter Solymos.
@@ -1281,9 +1292,9 @@
the species accumulation results from specaccum. The
function can use new self-starting species accumulation models
in vegan or other self-starting non-linear regression
-models in R. The function can fit Arrhenius, Gleason, Gitay,
+models in R. The function can fit Arrhenius, Gleason, Gitay,
Lomolino (in vegan), asymptotic, Gompertz,
-Michaelis-Menten, logistic and Weibull (in base R) models. The
+Michaelis-Menten, logistic and Weibull (in base R) models. The
function has plot and predict methods.
@@ -1292,7 +1303,7 @@
SSlomolino. These can be used with fitspecaccum or
directly in non-linear regression with nls. These functions
were implemented because they were found good for species-area
-models by Dengler (J. Biogeogr. 36, 728-744; 2009).
+models by Dengler (J. Biogeogr. 36, 728-744; 2009).
Diversity accumulation functions specaccum,
+renyiaccum, tsallisaccum, poolaccum and
+estaccumR use now permute package for permutations
+of the order of sampling sites. Normally these functions only
+need simple random permutation of sites, but restricted
+permutation of the permute package and user-supplied
+permutation matrices can be used.
+
+
+
estaccumR function can use parallel processing.
+
+
linestack accepts now expressions as labels. This
allows using mathematical symbols and formula given as
mathematical expressions.