Title

This is an R Markdown document. Markdown is a simple formatting syntax for authoring web pages (click the Help toolbar button for more details on using R Markdown).

When you click the Knit HTML button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

# Set dropbox path
droppath <- "C:/Users/Ben//Dropbox/"
data.df.null <- read.csv(paste(droppath, "Shared Ben and Catherine/DimDivRevision/500Iterations/Intervals_.9_.1/FinalDataNull.csv", 
    sep = ""))
require(proto)
## Loading required package: proto
require(ggplot2)
## Loading required package: ggplot2

StatEllipse <- proto(ggplot2:::Stat, {
    required_aes <- c("x", "y")
    default_geom <- function(.) GeomPath
    objname <- "ellipse"

    calculate_groups <- function(., data, scales, ...) {
        .super$calculate_groups(., data, scales, ...)
    }
    calculate <- function(., data, scales, level = 0.75, segments = 51, ...) {
        dfn <- 2
        dfd <- length(data$x) - 1
        if (dfd < 3) {
            ellipse <- rbind(c(NA, NA))
        } else {
            require(MASS)
            v <- cov.trob(cbind(data$x, data$y))
            shape <- v$cov
            center <- v$center
            radius <- sqrt(dfn * qf(level, dfn, dfd))
            angles <- (0:segments) * 2 * pi/segments
            unit.circle <- cbind(cos(angles), sin(angles))
            ellipse <- t(center + radius * t(unit.circle %*% chol(shape)))
        }

        ellipse <- as.data.frame(ellipse)
        colnames(ellipse) <- c("x", "y")
        return(ellipse)
    }
})

stat_ellipse <- function(mapping = NULL, data = NULL, geom = "path", position = "identity", 
    ...) {
    StatEllipse$new(mapping = mapping, data = data, geom = geom, position = position, 
        ...)
}

Scatter of all phylo trait combinations

p <- ggplot(data.df.null, aes(x = Phylosor.Phylo, y = MNTD, col = paste(Phylosor.Phylo_Null, 
    MNTD_Null))) + labs(x = "Phylogenetic Betadiversity", y = "Trait Betadiversity", 
    fill = "Phylo. Trait With Respect to Tax.", col = "Phylo. Trait With Respect to Tax.")
p + geom_point()

plot of chunk unnamed-chunk-3


# Just ellipses
p + stat_ellipse(geom = "polygon", alpha = 1/2, aes(fill = paste(Phylosor.Phylo_Null, 
    MNTD_Null))) + scale_color_discrete(guide = FALSE)
## Loading required package: MASS

plot of chunk unnamed-chunk-3


# Both
p + geom_point() + stat_ellipse(geom = "polygon", alpha = 1/2, aes(fill = paste(Phylosor.Phylo_Null, 
    MNTD_Null))) + scale_color_discrete(guide = FALSE)

plot of chunk unnamed-chunk-3

Without “Random”

p <- ggplot(data.df.null[!data.df.null$Phylosor.Phylo_Null %in% "Random" & !data.df.null$MNTD_Null %in% 
    "Random", ], aes(x = Phylosor.Phylo, y = MNTD, col = paste(Phylosor.Phylo_Null, 
    MNTD_Null))) + labs(x = "Phylogenetic Betadiversity", y = "Trait Betadiversity", 
    fill = "Phylo. Trait With Respect to Tax.", col = "Phylo. Trait With Respect to Tax.")
p + geom_point()

plot of chunk unnamed-chunk-4


# Just ellipses
p + stat_ellipse(geom = "polygon", alpha = 1/2, aes(fill = paste(Phylosor.Phylo_Null, 
    MNTD_Null))) + scale_color_discrete(guide = FALSE)

plot of chunk unnamed-chunk-4


# Both
p + geom_point(alpha = 0.8) + stat_ellipse(geom = "polygon", alpha = 1/2, aes(fill = paste(Phylosor.Phylo_Null, 
    MNTD_Null))) + scale_color_discrete(guide = FALSE)

plot of chunk unnamed-chunk-4