Bearloga has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/260762

Change subject: Add data selector
......................................................................

Add data selector

Change-Id: I7411663288e55b22d243cbc99320a5ffa238ab35
---
M NAMESPACE
M R/manipulate.R
A man/data_select.Rd
3 files changed, 39 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/discovery/polloi 
refs/changes/62/260762/1

diff --git a/NAMESPACE b/NAMESPACE
index 361ba70..1c33233 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -8,6 +8,7 @@
 export(cond_color)
 export(cond_icon)
 export(custom_axis_formatter)
+export(data_select)
 export(half)
 export(mad)
 export(make_dygraph)
diff --git a/R/manipulate.R b/R/manipulate.R
index dec529e..e946648 100644
--- a/R/manipulate.R
+++ b/R/manipulate.R
@@ -86,3 +86,18 @@
   n <- max(sapply(nm, nrow))
   do.call(cbind, lapply(nm, function (x) rbind(x, matrix(, n-nrow(x), 
ncol(x)))))
 }
+
+#'@title Conditionally Select A Dataset
+#'@description Like \code{ifelse}, but not awful and usable with
+#'  \code{data.frames}.
+#'@param test an object which can be coerced to logical mode.
+#'@param yes_set the dataset to return if \code{test} is true.
+#'@param no_set the dataset to return if \code{test} is false.
+#'@return The appropriate object.
+#'@export
+data_select <- function(test, yes_set, no_set){
+  if (test) {
+    return(yes_set)
+  }
+  return(no_set)
+}
diff --git a/man/data_select.Rd b/man/data_select.Rd
new file mode 100644
index 0000000..4833073
--- /dev/null
+++ b/man/data_select.Rd
@@ -0,0 +1,23 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/manipulate.R
+\name{data_select}
+\alias{data_select}
+\title{Conditionally Select A Dataset}
+\usage{
+data_select(test, yes_set, no_set)
+}
+\arguments{
+\item{test}{an object which can be coerced to logical mode.}
+
+\item{yes_set}{the dataset to return if \code{test} is true.}
+
+\item{no_set}{the dataset to return if \code{test} is false.}
+}
+\value{
+The appropriate object.
+}
+\description{
+Like \code{ifelse}, but not awful and usable with
+ \code{data.frames}.
+}
+

-- 
To view, visit https://gerrit.wikimedia.org/r/260762
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7411663288e55b22d243cbc99320a5ffa238ab35
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/discovery/polloi
Gerrit-Branch: master
Gerrit-Owner: Bearloga <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to