knitr::opts_chunk$set( collapse = TRUE, comment = "#>", out.width = ".8\\linewidth", fig.width = 10 )
library(biteme) # Loading the data fnames <- list.files("all_bites", pattern = "dyad", full.names = TRUE) dyads <- suppressMessages(lapply(fnames, readr::read_csv)) # Turning times into integers dyads <- lapply(dyads, function(x) { x$BiteTime_hms <- as.integer(x$BiteTime_hms) as.matrix(x[,1:2]) }) # Running the permutation tests cl <- parallel::makeForkCluster(8) ans02 <- perm_test(dyads[[2]], biteme:::timegap, R = 1e4, cl = cl) ans <- lapply( dyads, perm_test, statistic = biteme:::timegap, R = 100000, cl = cl ) parallel::stopCluster(cl)
plot(ans[[23]], breaks=100) plot(ans[[22]], breaks=100)
pvals<-unlist(sapply(ans, "[[", "pval", simplify = FALSE)) pvals <- sort(pvals) cols <- rep("tomato", length(pvals)) cols[which(pvals <= .05)] <- "steelblue" op <- par(mai = par()$mai + c(.5,0,0,0)) barplot(pvals, las=2, cex.names=1, col=cols, border=NA) abline(h=.05, lwd=2, lty=2) text(x = 2, y = .05, labels = "p-value 0.05", pos = 3) title( "p-values from the permuitation tests", xlab = "", ylab = "p-value" ) par(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.