Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#39] Fix yet more problems #41

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: cheddar
Type: Package
Title: Analysis and Visualisation of Ecological Communities
Version: 0.1-634
Version: 0.1-635
Date: 2020-02-11
Author: Lawrence Hudson with contributions from Dan Reuman and Rob Emerson
Maintainer: Lawrence Hudson <quicklizard@googlemail.com>
Expand Down
17 changes: 10 additions & 7 deletions R/community.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ Community <- function(nodes, properties, trophic.links=NULL)
c(reserved.tl.names, reserved.node.names))

# Title should be present. Must do this check before putting title first.
if(is.null(properties$title) || ''==properties$title)
if(is.null(properties$title) || 1!=length(properties$title) ||
''==properties$title)
{
stop(paste("The 'properties' parameter must contain a character",
"named 'title'"))
Expand Down Expand Up @@ -240,7 +241,7 @@ Community <- function(nodes, properties, trophic.links=NULL)
if('M' %in% colnames(nodes))
{
M <- nodes[,'M']
if(!class(M) %in% c('numeric', 'integer'))
if(!any(class(M) %in% c('numeric', 'integer')))
{
stop('M must contain numbers')
}
Expand All @@ -255,8 +256,9 @@ Community <- function(nodes, properties, trophic.links=NULL)
stop('Not all values in M can be NA')
}

if(is.null(properties$M.units) || ''==properties$M.units ||
'character'!=class(properties$M.units))
if(is.null(properties$M.units) || 1!=length(properties[['M.units']]) ||
''==properties[['M.units']] ||
'character'!=class(properties[['M.units']]))
{
stop(paste("The 'properties' parameter must contain an entry",
"named 'M.units'"))
Expand All @@ -267,7 +269,7 @@ Community <- function(nodes, properties, trophic.links=NULL)
if('N' %in% colnames(nodes))
{
N <- nodes[,'N']
if(!class(N) %in% c('numeric', 'integer'))
if(!any(class(N) %in% c('numeric', 'integer')))
{
stop('N must contain numbers')
}
Expand All @@ -282,8 +284,9 @@ Community <- function(nodes, properties, trophic.links=NULL)
stop('Not all values in N can be NA')
}

if(is.null(properties$N.units) || ''==properties$N.units ||
'character'!=class(properties$N.units))
if(is.null(properties$N.units) || 1!=length(properties[['N.units']]) ||
''==properties[['N.units']] ||
'character'!=class(properties[['N.units']]))
{
stop(paste("The 'properties' parameter must contain an entry",
"named 'N.units'"))
Expand Down
2 changes: 1 addition & 1 deletion man/cheddar.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ release history:
\tabular{ll}{
Package: \tab cheddar\cr
Type: \tab Package\cr
Version: \tab 0.1-634\cr
Version: \tab 0.1-635\cr
Date: \tab 2020-02-11\cr
License: \tab BSD 2 clause\cr
}
Expand Down