-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
18 changed files
with
78 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ $RECYCLE.BIN/ | |
# Operating System Files | ||
# ========================= | ||
.Rproj.user | ||
README.Rmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,63 @@ | ||
#' @title Subsampling of entire network | ||
#' | ||
#' @description | ||
#' This function iteratively samples the entire network and generates a data frame with sub-sample host and affilaite richness tallied together | ||
#' This function iteratively samples the entire network and generates | ||
#' a data frame with sub-sample host and affilaite richness tallied together | ||
#' | ||
#' @param assoc.df The raw dataset of associations (pairs of names in two columns, hosts and affiliates) | ||
#' @param iter Number of iterations required for each subsample | ||
#' @param assoc.df The raw dataset of associations (pairs of names in | ||
#' two columns, hosts and affiliates) | ||
#' | ||
#' @param iter Number of iterations required for each subsample | ||
#' @param subSample Fraction of host species to subsample for richness estimation | ||
#' @export | ||
|
||
<<<<<<< HEAD | ||
curve.df <- function(assoc.df, iter, subSample=0){ | ||
======= | ||
curve.df <- function(assoc.df, iter, subSample=NULL){ | ||
|
||
if(!is.null(subSample)){ | ||
hostlist <- unique(assoc.df[,1]) | ||
hostCut <- sample(hostlist, round(subSample*hostlist,0), replace = FALSE) | ||
assoc.df <- assoc.df[assoc.df[,1] %in% hostCut,] | ||
} | ||
>>>>>>> origin/master | ||
|
||
# placeholder: Tad add subsample at this level because you didn't | ||
u.hosts <- unique(assoc.df[,1]) | ||
n.hosts <- length(u.hosts) | ||
|
||
results.df <- data.frame(n.host=0,n.par=0) | ||
results.df <- results.df[-1,] | ||
oneSp <- function(x, i=iter){ | ||
df<- vapply(1:iter, FUN.VALUE=c(double(1), double(1)), | ||
function(a){ | ||
sub.hosts <- sample(u.hosts, x) | ||
sub.df <- assoc.df[assoc.df[,1] %in% sub.hosts,] | ||
u.par <- unique(sub.df[,2]) | ||
n.par <- length(u.par) | ||
return(c(x, n.par)) | ||
}) | ||
return(t(df)) | ||
} | ||
|
||
results.df <- lapply(1:n.hosts, | ||
oneSp, i=iter) | ||
ret <- do.call(rbind, results.df) | ||
colnames(ret) <- c('n.host', 'n.par') | ||
return(ret) | ||
} | ||
|
||
|
||
|
||
|
||
for (i in 1:n.hosts) { | ||
#for (i in 1:5) { | ||
for (j in 1:iter) { | ||
|
||
sub.hosts <- sample(u.hosts,i) | ||
sub.df <- assoc.df[assoc.df[,1] %in% sub.hosts,] | ||
u.par <- unique(sub.df[,2]) | ||
n.par <- length(u.par) | ||
|
||
<<<<<<< HEAD | ||
results.df[nrow(results.df)+1,] <- c(i, n.par) | ||
} | ||
#print(i) | ||
} | ||
results.df <- data.frame(results.df) | ||
return(results.df) | ||
} | ||
======= | ||
>>>>>>> origin/master |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ Author | |
|
||
Colin J. Carlson ([email protected]) | ||
|
||
(Contributions by Tad Dallas!) | ||
|
||
Installing the package | ||
---------------------- | ||
|
||
|
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.