From 001d7a7c6d7ac7a0f1b3a05e73cccfc75c625a35 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Tue, 28 Jul 2020 10:28:15 +0200 Subject: [PATCH] Added base function isspace() --- R/isspace.R | 11 +++++++++++ man/isspace.Rd | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 R/isspace.R create mode 100644 man/isspace.Rd diff --git a/R/isspace.R b/R/isspace.R new file mode 100644 index 0000000..a4ee2d7 --- /dev/null +++ b/R/isspace.R @@ -0,0 +1,11 @@ +#' @title Determine space characters +#' @description Determine which characters are space characters +#' @param A a character array or a string scalar +#' @return a vector TF such that the elements of TF are logical 1 (true) where corresponding characters in A are space characters, and logical 0 (false) elsewhere +#' @note Recognized whitespace characters are ` ` and `\\t`. +#' @author Waldir Leoncio +isspace <- function(A) { + A_split <- unlist(strsplit(A, '')) + TF <- A_split %in% c(' ', '\t') + return(as.numeric(TF)) +} \ No newline at end of file diff --git a/man/isspace.Rd b/man/isspace.Rd new file mode 100644 index 0000000..fba4844 --- /dev/null +++ b/man/isspace.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/isspace.R +\name{isspace} +\alias{isspace} +\title{Determine space characters} +\usage{ +isspace(A) +} +\arguments{ +\item{A}{a character array or a string scalar} +} +\value{ +a vector TF such that the elements of TF are logical 1 (true) where corresponding characters in A are space characters, and logical 0 (false) elsewhere +} +\description{ +Determine which characters are space characters +} +\note{ +Recognized whitespace characters are ` ` and `\\t`. +} +\author{ +Waldir Leoncio +}