Skip to content

Commit

Permalink
Added last fixes to cran check errors #38
Browse files Browse the repository at this point in the history
  • Loading branch information
emhart committed Mar 2, 2015
1 parent 41e4f99 commit 3f92bd9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 53 deletions.
52 changes: 4 additions & 48 deletions R/algorithms.R
Expand Up @@ -300,50 +300,6 @@ matrix(vector_sample(speciesData,weights=matrixWeights),ncol=ncol(speciesData))



###############################################
######################################################################

# sim9 function
# @description Takes a binary presence absence matrix returns a new matrix
# with same number of rows and columns uses swapping function from Denitz

# Not used preserved for posterity
# sim9 <- function(speciesData=matrix(rbinom(100,1,0.5),nrow=10))

#{
# speciesData <- speciesData[which(rowSums(speciesData)>0),] # make
# calculation on submatrix with no missing species
#
# Burn.In <- max(c(10*nrow(speciesData),1000)) # set the burn-in
# # select two random rows and create submatrix
# for(i in 1:Burn.In)
# {
# ran.rows <- sample(nrow(speciesData),2)
#
# speciesData.pair <- speciesData[ran.rows,]
#
#
#
# # find columns if any in pair for which colsum =1; these can be swapped
#
# Sum.Is.One <- which(colSums(speciesData.pair)==1)
#
# if(length(Sum.Is.One)>1)
# {
# # swap them in speciesData.pair.swapped
# speciesData.pair.swapped <- speciesData.pair
# speciesData.pair.swapped[,Sum.Is.One] <- speciesData.pair[,sample(Sum.Is.One)]
#
# # return the two swapped rows to the original speciesData matrix
#
# speciesData[ran.rows,] <- speciesData.pair.swapped
#
# }
# }
# return(speciesData)
#}


#' Sim10 Co-occurrence Randomization Algorithm
#' @description Randomizes a binary matrix speciesData by reshuffling all
#' elements. Rows and column probabilities are proportional to user-supplied
Expand Down Expand Up @@ -401,7 +357,7 @@ matrix(vector_sample(speciesData, weights =matrixWeights),ncol=ncol(speciesData)
#' resource categories) may include zeroes, but no negative numbers or missing
#' values. Relative resource within a species is first calculated, so the rows
#' need not sum to 1.0.
#' @param m a resource utilization matrix (rows = species, columns = discrete
#' @param speciesData a resource utilization matrix (rows = species, columns = discrete
#' resource states) filled with non-negative real numbers.
#' @return Returns a random utilization matrix with the same dimensions as the
#' input matrix.
Expand Down Expand Up @@ -435,7 +391,7 @@ matrix(runif(prod(dim(speciesData))),ncol=ncol(speciesData))
#' resource categories) may include zeroes, but no negative numbers or missing
#' values. Relative resource within a species is first calculated, so the rows
#' need not sum to 1.0.
#' @param m a resource utilization matrix (rows = species, columns = discrete
#' @param speciesData a resource utilization matrix (rows = species, columns = discrete
#' resource states) filled with non-negative real numbers.
#' @return Returns a random utilization matrix with the same dimensions as the
#' input matrix.
Expand Down Expand Up @@ -475,7 +431,7 @@ return(RM)
#' resource categories) may include zeroes, but no negative numbers or missing
#' values. Relative resource within a species is first calculated, so the rows
#' need not sum to 1.0.
#' @param m a resource utilization matrix (rows = species, columns = discrete
#' @param speciesData a resource utilization matrix (rows = species, columns = discrete
#' resource states) filled with non-negative real numbers.
#' @return Returns a random utilization matrix with the same dimensions as the
#' input matrix.
Expand Down Expand Up @@ -507,7 +463,7 @@ return(RM)
#' resource categories) may include zeroes, but no negative numbers or missing
#' values. Relative resource within a species is first calculated, so the rows
#' need not sum to 1.0.
#' @param m a resource utilization matrix (rows = species, columns = discrete
#' @param speciesData a resource utilization matrix (rows = species, columns = discrete
#' resource states) filled with non-negative real numbers.
#' @return Returns a random utilization matrix with the same dimensions as the
#' input matrix.
Expand Down
2 changes: 1 addition & 1 deletion R/coccurrence_null.R
Expand Up @@ -73,7 +73,7 @@ cooc_null_model <- function(speciesData, algo = "sim1", metric = "c_score", nRep
#' @param object the null model object to print a summary.
#' @export

summary.coocnullmod <- function(object,...)
summary.coocnullmod <- function(object)
{
nullmodObj <- object
cat("Time Stamp: " , nullmodObj$Time.Stamp, "\n")
Expand Down
5 changes: 3 additions & 2 deletions R/niche_overlap_null.R
Expand Up @@ -34,16 +34,17 @@ niche_null_model <- function(speciesData, algo = "ra3", metric = "pianka", nReps
output <- do.call(null_model_engine,params)
class(output) <- "nichenullmod"
return(output)

}


#' Generic function for calculating null model summary statistics
#' @description Takes as input a list of Null.Model.Out, with Obs, Sim, Elapsed Time, and Time Stamp values
#' @param object the null model object to print a summary of.
#' @aliases
#' @export

summary.nichenullmod <- function(object,...)
summary.nichenullmod <- function(object)
{

nullmodObj <- object
Expand Down
9 changes: 8 additions & 1 deletion R/sim9fast.R
@@ -1,6 +1,13 @@
#' Sim9.fast function
#' @description Special implementation of sequential swap algorithm.

#'@param speciesData a dataframe <put some guidelines in here>
#'@param algo the algorithm to use, must be "RA1", "RA2", "RA3", "RA4"
#'@param metric the metric used to caluclate the null model: choices are "Pianka", "Czekanowski", "Pianka.var", "Czekanowski.var", "Pianka.skew", "Czekanowski.skew"; default is Pianka
#'@param nReps the number of replicates to run the null model.
#'@param rowNames Does your dataframe have row names? If yes, they are stripped, otherwise FALSE for data that has no row names
#'@param saveSeed Should the existing random seed be saved to make the model reproducible?
#'@param burn_in The number of reps to burn in the swap algo
#' @details Due to the extra swapping steps, this needs it's own special null model type engine for sim9. So this fulfills that need.
#' @export


Expand Down
3 changes: 2 additions & 1 deletion R/sizeratio_null.R
Expand Up @@ -57,7 +57,7 @@ size_null_model <- function(speciesData, algo = "size_uniform", metric = "var_ra
#' @param object the null model object to print a summary of.
#' @export

summary.sizenullmod <- function(object,...)
summary.sizenullmod <- function(object)
{
nullmodObj <- object
#if (!is.null(Output.File)) outfile <- file(p$Output.File, "w") else outfile <-""
Expand Down Expand Up @@ -101,6 +101,7 @@ summary.sizenullmod <- function(object,...)
#' @description plot a variety of size null models
#' @param x the null model to plot
#' @param type the type of null plot to make. See details for more information
#' @param ... Other variables to be passed on to base plotting
#' @details the valid types for size are "hist" to show a histogram and "size" to show a sample size null model.
#' @export

Expand Down

0 comments on commit 3f92bd9

Please sign in to comment.