-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the as.alienData function with help file written in roxygen2 (#2)
* Added the as.alienData function with help file written in roxygen2 * CamelCase functions * restore Bartomeus data file in R/ * Fixing issue with weight_sd and weight_mean functions * removin weight_mean and weigthed_sd, already present in stats - close #17 * Rebuild package and add new clean target in makefile * fixinx syntax issues * code review; fix minor issues/syntax errors * Set mandatory idObs object in as.alienData() #21 * cleaning up data format * removing ressourceConsumer matrix * Details on roxygen documentation * Add data consistency among interacPair and idObs #21 * set build interac matrix #21 * Add interacSp and interacInd from interacPair * finish to reference interacSp and interacInd with idObs #21 * check consistency among traitSp and traitInd with idObs #21 * imp. coOcc methods: inferred or not; last checks on out objects; make sure coOcc rownames and colnames reffered to idObs * make sure siteEnv are referenced in idObs #21 * build doc of as.alienData function * Push last edits on as.alienData function * set traitSp and traitInd as long format * fixing functions errors * Fixing last issue with res * building docs; and close #21 * Add data and test it * Add comments on as.alienData posible enhancements * set Nacho's comments in issue #12 * set bartomeus in data folder * init as.alienData test * init test on integrity #18 * cover unit tests as.alienData() - issue #18 * add unit tests to data structure issue #18
- Loading branch information
1 parent
d4e1bf7
commit fa9b0a7
Showing
10 changed files
with
665 additions
and
13 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 |
---|---|---|
@@ -1,19 +1,14 @@ | ||
rfun := $(wildcard R/*.R) | ||
rman := $(wildcard man/) | ||
rtes := $(wildcard tests/testthat/*.R) | ||
rdm = README.Rmd | ||
md = README.md | ||
chk = record_updates.txt | ||
rscr = pkg2date.R | ||
|
||
|
||
all: $(md) $(chk) | ||
|
||
$(md): $(rdm) | ||
Rscript --no-site-file --no-init-file $(rscr) 0 | ||
all: $(chk) | ||
|
||
$(chk): $(rfun) $(rtes) $(rman) | ||
Rscript --no-site-file --no-init-file $(rscr) 1 | ||
|
||
clean: | ||
rm -rf man/* NAMESPACES | ||
rm -rf man/* NAMESPACE |
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
Large diffs are not rendered by default.
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
Binary file not shown.
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.
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
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
context("alienData function") | ||
|
||
load('./argsAlienData.RData') | ||
out <- as.alienData(idObs=idObs,interactPair=interactPair,traitSp=traitSp,traitInd=traitInd,verbose=FALSE) | ||
|
||
test_that("check data structure", { | ||
expect_is(out, "alienData") | ||
# Even if items from the list are NULL, all items have to be returned | ||
expect_equal(names(out),c("idObs","interactSp","interactInd","coOcc","coAbund","siteEnv","traitSp","traitInd","phylo")) | ||
}) | ||
|
||
test_that("check data integrity", { | ||
|
||
# Generate fake data for idObs | ||
len <- 3 | ||
sites <- sample(paste("site",letters[1:3],sep="_"),len,replace=TRUE) # 3 sites | ||
sp <- paste0("sp",sample(1:len,len,replace=TRUE)) # 3 species | ||
ind <- 1:len # 3 individus | ||
idObs <- data.frame(idSite=sites,idTime=rep(NA,len),idSp=sp, idInd=ind,stringsAsFactors=FALSE) | ||
|
||
interactPair <- data.frame(idTo=c("1","sp1"),idFrom=c("1","2"),strength=c(NA,NA),verbose=FALSE,stringsAsFactors=FALSE) | ||
expect_error(as.alienData(idObs=idObs, interactPair=interactPair,verbose=FALSE),"'idTo' values belongs to 'idSp' and 'idInd' in 'idObs'. Interaction can't be at the species AND individual levels") | ||
|
||
interactPair <- data.frame(idTo=c("1","2"),idFrom=c("sp1","2"),strength=c(NA,NA),verbose=FALSE,stringsAsFactors=FALSE) | ||
expect_error(as.alienData(idObs=idObs, interactPair=interactPair,verbose=FALSE),"'idFrom' values belongs to 'idSp' and 'idInd' in 'idObs'. Interaction can't be at the species AND individual levels") | ||
|
||
interactPair <- data.frame(idTo="sp4",idFrom="sp1",strength=NA,stringsAsFactors=FALSE) | ||
expect_error(as.alienData(idObs=idObs, interactPair=interactPair,verbose=FALSE),"Some species ids in 'idTo' are not in 'idObs'") | ||
|
||
interactPair <- data.frame(idTo="4",idFrom="1",strength=NA,stringsAsFactors=FALSE) | ||
expect_error(as.alienData(idObs=idObs, interactPair=interactPair,verbose=FALSE),"Some individus ids in 'idTo' are not in 'idObs'") | ||
|
||
interactPair <- data.frame(idTo="sp1",idFrom="sp4",strength=NA,stringsAsFactors=FALSE) | ||
expect_error(as.alienData(idObs=idObs, interactPair=interactPair,verbose=FALSE),"Some species ids in 'idFrom' are not in 'idObs'") | ||
|
||
interactPair <- data.frame(idTo="1",idFrom="4",strength=NA,stringsAsFactors=FALSE) | ||
expect_error(as.alienData(idObs=idObs, interactPair=interactPair,verbose=FALSE),"Some individus ids in 'idFrom' are not in 'idObs'") | ||
|
||
interactPair <- data.frame(idTo=c("2","2","3"),idFrom=c("2","2","2"),strength=c(NA,NA,NA),verbose=FALSE,stringsAsFactors=FALSE) | ||
expect_error(as.alienData(idObs=idObs, interactPair=interactPair,verbose=FALSE),"Some 'idFrom' and 'idTo' are duplicated") | ||
|
||
}) |