Skip to content
Open
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
20 changes: 15 additions & 5 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

\item \code{confint.default()} now also works on S4 objects, as long as
suitable \code{coef()} and \code{vcov()} methods exist.
\preformatted{
obj <- new("MyS4Class")
confint(obj)
}

\item \code{binomial(identity)} and \code{quasibinomial(identity)} now work
without having to quote the argument.
Expand All @@ -48,6 +52,10 @@
\samp{R >= 4.6.0}.

\item \code{tools::analyze_license()} now also computes
\abbr{SPDX} license identifiers. Example usage:
\preformatted{
tools::analyze_license("DESCRIPTION")
}
\href{https://spdx.dev/learn/handling-license-info/}{\abbr{SPDX}
license identifiers},
thanks to \I{Thierry Onkelinx} and \I{LLuís Revilla}.
Expand Down Expand Up @@ -126,10 +134,12 @@
to allow literal pattern matching. Suggested and implemented
by \I{Duncan Murdoch} in \PR{18925}.

\item \code{substring(txt, i1, i2)}, \code{substr(..)} and their
replacement versions now accept \code{i2 = NULL} to mean \dQuote{to
the end_of_string}, thus fulfilling \I{Kevin Ushey} (and others')
suggestions in \PR{18851}.
\item \code{substring(txt, i1, i2)} now accepts \code{i2 = NULL}
to mean "to the end of string". Example:
\preformatted{
substring("Hello World", 7) # returns "World"
substring("Hello World", 7, NULL) # same result
}

\item The default method for \code{pretty()} gets a new switch \code{bounds} for
completeness, corresponding to \code{.pretty()}. Also, it now
Expand Down Expand Up @@ -6679,5 +6689,5 @@
\ifelse{html}{\url{NEWS.3.html}}{\file{doc/html/NEWS.3.html}}
and
\ifelse{html}{\url{NEWS.2.html}}{\file{doc/html/NEWS.2.html}}.
}
} 
}
8 changes: 5 additions & 3 deletions src/library/base/man/paste.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ paste0(\dots, collapse = NULL, recycle0 = FALSE)
the result is always a string (\code{\link{character}} of length 1).}
\item{recycle0}{\code{\link{logical}} indicating if zero-length
character arguments should result in the zero-length
\code{\link{character}(0)}. Note that when \code{collapse} is
\code{\link{character}(0)}. Note that when \code{collapse} is
a string, \code{recycle0} does \emph{not} recycle to zero-length, but
to \code{""}.}% <== basic semantic of {collapse} mentioned above
to \code{""}. This ensures that a single character string is always
returned when \code{collapse} is specified.}% <== basic semantic of {collapse} mentioned above
}
\description{
Concatenate vectors after converting to character.
Expand All @@ -46,7 +47,8 @@ paste0(\dots, collapse = NULL, recycle0 = FALSE)
desirable, e.g.\sspace{}in \code{paste("the value of p is ", p)}.

\code{paste0(\dots, collapse)} is equivalent to
\code{paste(\dots, sep = "", collapse)}, slightly more efficiently.
\code{paste(\dots, sep = "", collapse)}, slightly more efficiently
as it avoids handling a separator.

If a value is specified for \code{collapse}, the values in the result
are then concatenated into a single string, with the elements being
Expand Down
7 changes: 7 additions & 0 deletions src/library/base/man/substr.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ substring(text, first, last = NULL) <- value
If an input element has declared \code{"bytes"} encoding (see
\code{\link{Encoding}}), the subsetting is done in units of bytes not
characters.
When \code{start} or \code{stop} results in a zero-length extraction, an empty string
\code{""} is returned. Recycling is done to match the length of the longest input
vector, ensuring consistent behavior for vectorized operations.
}
\value{
For \code{substr}, a character vector of the same length and with the
Expand Down Expand Up @@ -111,5 +114,9 @@ substring(x, 2) <- c("..", "+++")
substring(X, 2) <- c("..", "+++")
X
stopifnot(x == X, identical(aX, attributes(X)), nzchar(comment(X)))

## Demonstrating zero-length extraction behavior
substr(character(0), 1, 2) # returns character(0)
substring(c("abc", ""), 2) # returns "bc" and ""
}
\keyword{character}