Skip to content

Commit

Permalink
More options for articlebeforenumber
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed May 7, 2023
1 parent c3097a8 commit 46a03b3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: spatstat.utils
Version: 3.0-2.002
Date: 2023-05-06
Version: 3.0-2.003
Date: 2023-05-07
Title: Utility Functions for 'spatstat'
Authors@R: c(person("Adrian", "Baddeley",
role = c("aut", "cre"),
Expand Down
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

CHANGES IN spatstat.utils VERSION 3.0-2.002
CHANGES IN spatstat.utils VERSION 3.0-2.003

OVERVIEW

Expand All @@ -13,6 +13,9 @@ SIGNIFICANT USER-VISIBLE CHANGES
o articlebeforenumber
Now handles non-integer values correctly.

o articlebeforenumber
New argument 'teenhundreds'.

CHANGES IN spatstat.utils VERSION 3.0-2

OVERVIEW
Expand Down
10 changes: 8 additions & 2 deletions R/utiltext.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#'
#' Utilities for text output, etc
#'
#' $Revision: 1.13 $ $Date: 2023/05/06 10:53:29 $
#' $Revision: 1.14 $ $Date: 2023/05/07 09:52:27 $
#'

# text magic
Expand Down Expand Up @@ -225,7 +225,7 @@ ordinalsuffix <- function(k) {
return(ending)
}

articlebeforenumber <- function(k) {
articlebeforenumber <- function(k, teenhundreds=FALSE) {
if(k < 0) return("a")
k <- floor(k)
if(k == 0) return("a")
Expand All @@ -235,6 +235,12 @@ articlebeforenumber <- function(k) {
## leading digits in front of power of 1000
kilo <- floor(k/10^(3*floor(log10(k)/3)))
if(kilo == 11 || kilo == 18) return("an")
##
if(teenhundreds) {
hundreds <- floor(k/100)
if(hundreds == 11 || hundreds == 18)
return("an")
}
return("a")
}

Expand Down
2 changes: 1 addition & 1 deletion inst/doc/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
"2021-12-12" "2.3-0" 35 183 0 3594 2012
"2022-10-19" "3.0-1" 39 186 0 3642 2031
"2023-03-11" "3.0-2" 39 186 0 3655 2031
"2023-05-06" "3.0-2.002" 39 186 0 3661 2031
"2023-05-07" "3.0-2.003" 39 186 0 3667 2031
25 changes: 20 additions & 5 deletions man/articlebeforenumber.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,34 @@
Indefinite Article Preceding A Number
}
\description{
Determines the indefinite article (\emph{an} or \code{a}) which should
Determines the indefinite article (\emph{an} or \emph{a}) which should
precede a given number, if the number is read out in English.
}
\usage{
articlebeforenumber(k)
articlebeforenumber(k, teenhundreds=FALSE)
}
\arguments{
\item{k}{A single integer.}
\item{k}{A single number.}
\item{teenhundreds}{
Logical value specifying that (for example)
1800 should be read as \dQuote{eighteen hundred}
instead of \dQuote{one thousand eight hundred}.
See Details.
}
}
\details{
This function applies the rule that,
if the English word for the number \code{k} begins with a vowel, then
it should be preceded by \code{an}, and otherwise by \code{a}.
if the English language word or phrase for the number \code{k}
begins with a vowel, then it should be preceded by \emph{an},
and otherwise by \emph{a}.

If \code{teenhundreds=FALSE} (the default),
the numbers 1100 and 1800 will be read as
\sQuote{one thousand one hundred} and \sQuote{one thousand eight hundred},
and the indefinite article will be \emph{a}.
However if \code{teenhundreds=TRUE}, the numbers 1100 and 1800
be read as \sQuote{eleven hundred} and \sQuote{eighteen hundred}
and the indefinite article will be \emph{an}.
}
\value{
One of the character strings \code{"an"} or \code{"a"}.
Expand Down

0 comments on commit 46a03b3

Please sign in to comment.