Skip to content

Commit

Permalink
[#39] Fix yet more problems
Browse files Browse the repository at this point in the history
  • Loading branch information
quicklizard99 committed Feb 11, 2020
1 parent 06b2152 commit 2b094d6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
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

0 comments on commit 2b094d6

Please sign in to comment.