Bearloga has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/375078 )

Change subject: Add function 'null2na'
......................................................................


Add function 'null2na'

Change-Id: Id149be60ae41c9f09d81b91aaf6a1ee9ecc8db3b
---
M DESCRIPTION
M NAMESPACE
A R/utils.R
M man/FiveThirtyNine.Rd
M man/build_query.Rd
M man/date_clause.Rd
M man/get_logfile.Rd
M man/global_query.Rd
M man/mysql.Rd
A man/null2na.Rd
M man/query_hive.Rd
M man/read_sampled_log.Rd
M man/rewrite_conditional.Rd
M man/sample_size_effect.Rd
M man/sample_size_odds.Rd
M man/set_proxies.Rd
M man/timeconverters.Rd
M man/write_conditional.Rd
18 files changed, 49 insertions(+), 24 deletions(-)

Approvals:
  Bearloga: Verified; Looks good to me, approved



diff --git a/DESCRIPTION b/DESCRIPTION
index f739244..b8fe3d1 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -21,4 +21,4 @@
     projects=Discovery-Analysis
 Suggests:
     testthat
-RoxygenNote: 5.0.1
+RoxygenNote: 6.0.1
diff --git a/NAMESPACE b/NAMESPACE
index 4a137c4..6a737d2 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -12,6 +12,7 @@
 export(mysql_exists)
 export(mysql_read)
 export(mysql_write)
+export(null2na)
 export(query_hive)
 export(read_sampled_log)
 export(rewrite_conditional)
diff --git a/R/utils.R b/R/utils.R
new file mode 100644
index 0000000..91f3e7e
--- /dev/null
+++ b/R/utils.R
@@ -0,0 +1,18 @@
+#'@title Turns Null Into Character "NA"
+#'@description The function turns NULL in a list into character "NA".
+#'
+#'@param x A list
+#'
+#'@return If any element from the input list is NULL, they will be turned into 
character
+#'  "NA". Otherwise, return the original list.
+#'
+#'@export
+null2na <- function(x) {
+  return(lapply(x, function(y) {
+    if (is.null(y)) {
+      return(as.character(NA))
+    } else {
+      return(y)
+    }
+  }))
+}
diff --git a/man/FiveThirtyNine.Rd b/man/FiveThirtyNine.Rd
index fb66530..7b129ce 100644
--- a/man/FiveThirtyNine.Rd
+++ b/man/FiveThirtyNine.Rd
@@ -20,4 +20,3 @@
  allow for long titles) back in and does a small amount of reduction of the
  overall plot size to avoid an absolute ton of extraneous spacing.
 }
-
diff --git a/man/build_query.Rd b/man/build_query.Rd
index 8f73d7a..649388b 100644
--- a/man/build_query.Rd
+++ b/man/build_query.Rd
@@ -19,4 +19,3 @@
 constructs a MySQL query with a conditional around date.
 This is aimed at eventlogging, where the date/time is always "timestamp".
 }
-
diff --git a/man/date_clause.Rd b/man/date_clause.Rd
index b2736b6..59a2faf 100644
--- a/man/date_clause.Rd
+++ b/man/date_clause.Rd
@@ -17,4 +17,3 @@
 what it says on the tin; generates a "WHERE year = foo AND month = bar" using 
lubridate
 that can then be combined with other elements to form a Hive query.
 }
-
diff --git a/man/get_logfile.Rd b/man/get_logfile.Rd
index 00e28d9..f8f88a2 100644
--- a/man/get_logfile.Rd
+++ b/man/get_logfile.Rd
@@ -24,4 +24,3 @@
 sampled log files; it can be used to retrieve a particular date range of
 files through the "earliest" and "latest" arguments.
 }
-
diff --git a/man/global_query.Rd b/man/global_query.Rd
index f07525c..277b903 100644
--- a/man/global_query.Rd
+++ b/man/global_query.Rd
@@ -15,12 +15,11 @@
 \code{global_query} is a simple wrapper around the mysql queries that allows a 
useR to send a query to all production
 dbs on analytics-store.eqiad.wmnet, joining the results from each query into a 
single object.
 }
-\author{
-Oliver Keyes <[email protected]>
-}
 \seealso{
 \code{\link{mysql_read}} for querying an individual db, 
\code{\link{mw_strptime}}
 for converting MediaWiki timestamps into POSIXlt timestamps, or 
\code{\link{hive_query}} for
 accessing the Hive datastore.
 }
-
+\author{
+Oliver Keyes <[email protected]>
+}
diff --git a/man/mysql.Rd b/man/mysql.Rd
index de36b60..a7913dc 100644
--- a/man/mysql.Rd
+++ b/man/mysql.Rd
@@ -2,12 +2,12 @@
 % Please edit documentation in R/mysql.R
 \name{mysql}
 \alias{mysql}
-\alias{mysql_close}
 \alias{mysql_connect}
-\alias{mysql_disconnect}
-\alias{mysql_exists}
 \alias{mysql_read}
+\alias{mysql_exists}
 \alias{mysql_write}
+\alias{mysql_close}
+\alias{mysql_disconnect}
 \title{Work with MySQL databases}
 \usage{
 mysql_connect(database, default_file = NULL)
@@ -43,4 +43,3 @@
 \seealso{
 \code{\link{hive_query}} or \code{\link{global_query}}
 }
-
diff --git a/man/null2na.Rd b/man/null2na.Rd
new file mode 100644
index 0000000..9f54b7a
--- /dev/null
+++ b/man/null2na.Rd
@@ -0,0 +1,18 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/utils.R
+\name{null2na}
+\alias{null2na}
+\title{Turns Null Into Character "NA"}
+\usage{
+null2na(x)
+}
+\arguments{
+\item{x}{A list}
+}
+\value{
+If any element from the input list is NULL, they will be turned into character
+ "NA". Otherwise, return the original list.
+}
+\description{
+The function turns NULL in a list into character "NA".
+}
diff --git a/man/query_hive.Rd b/man/query_hive.Rd
index 8483052..fb7886f 100644
--- a/man/query_hive.Rd
+++ b/man/query_hive.Rd
@@ -48,6 +48,7 @@
 which should help if you want to engage in that; the example provided is a 
user agent parser, allowing you to
 get the equivalent of \code{\link{ua_parse}}'s output further upstream.
 }
+
 \examples{
 \dontrun{
 query_hive("USE wmf; DESCRIBE webrequest;")
@@ -58,4 +59,3 @@
 \code{\link{log_strptime}} for converting the "dt" column in the webrequests 
table to POSIXlt,
 and \code{\link{mysql_query}} and \code{\link{global_query}} for querying our 
MySQL databases.
 }
-
diff --git a/man/read_sampled_log.Rd b/man/read_sampled_log.Rd
index 3baa690..19e4310 100644
--- a/man/read_sampled_log.Rd
+++ b/man/read_sampled_log.Rd
@@ -25,4 +25,3 @@
 The sampled logs are returned as a data.frame with 16 columns - see
  the "Value" documentation.
 }
-
diff --git a/man/rewrite_conditional.Rd b/man/rewrite_conditional.Rd
index 953d388..5c6d377 100644
--- a/man/rewrite_conditional.Rd
+++ b/man/rewrite_conditional.Rd
@@ -18,4 +18,3 @@
 writes out temporal data to a file while ensuring
 the file only has \code{n_days} worth of data in it.
 }
-
diff --git a/man/sample_size_effect.Rd b/man/sample_size_effect.Rd
index 88ddd2b..9b98aae 100644
--- a/man/sample_size_effect.Rd
+++ b/man/sample_size_effect.Rd
@@ -32,4 +32,3 @@
 sample_size_effect(w = 0.1, groups = 3, sig_level = 0.001, power = 0.9)
 
 }
-
diff --git a/man/sample_size_odds.Rd b/man/sample_size_odds.Rd
index ad73b92..8f4f364 100644
--- a/man/sample_size_odds.Rd
+++ b/man/sample_size_odds.Rd
@@ -46,6 +46,7 @@
  Statistics}, \strong{12}(4), 471–483.
  \url{http://doi.org/10.1081/BIP-120016231}
 }
+
 \examples{
 sample_size_odds(p_treatment = 0.4, p_control = 0.25, power = 0.8)
 sample_size_odds(odds_ratio = 2, p_control = 0.4, power = c(0.8, 0.9, 0.95))
@@ -53,4 +54,3 @@
 sample_size_odds(odds_ratio = 2, p_control = 0.4, visualize = TRUE)
 
 }
-
diff --git a/man/set_proxies.Rd b/man/set_proxies.Rd
index 685932e..aaf21f6 100644
--- a/man/set_proxies.Rd
+++ b/man/set_proxies.Rd
@@ -21,4 +21,3 @@
 }
 
 }
-
diff --git a/man/timeconverters.Rd b/man/timeconverters.Rd
index d192809..ca01ef0 100644
--- a/man/timeconverters.Rd
+++ b/man/timeconverters.Rd
@@ -1,11 +1,11 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/time.R
 \name{timeconverters}
-\alias{from_log}
-\alias{from_mediawiki}
 \alias{timeconverters}
-\alias{to_log}
+\alias{from_mediawiki}
+\alias{from_log}
 \alias{to_mediawiki}
+\alias{to_log}
 \title{convert to and from common timestamp formats}
 \usage{
 from_mediawiki(x)
@@ -25,4 +25,3 @@
 \examples{
 from_mediawiki("20150101010301")
 }
-
diff --git a/man/write_conditional.Rd b/man/write_conditional.Rd
index 6124f0f..5d4ad2e 100644
--- a/man/write_conditional.Rd
+++ b/man/write_conditional.Rd
@@ -15,4 +15,3 @@
 if the file already exists, append. If it
 doesn't, create!
 }
-

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id149be60ae41c9f09d81b91aaf6a1ee9ecc8db3b
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/discovery/wmf
Gerrit-Branch: master
Gerrit-Owner: Chelsyx <[email protected]>
Gerrit-Reviewer: Bearloga <[email protected]>

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

Reply via email to