[med-svn] [r-cran-plyr] 01/04: Imported Upstream version 1.8.3
Andreas Tille
tille at debian.org
Sun Jun 28 05:58:18 UTC 2015
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository r-cran-plyr.
commit f896cb75d9b4f5f0fca0972420fa99ad247b0446
Author: Andreas Tille <tille at debian.org>
Date: Sun Jun 28 00:19:00 2015 +0200
Imported Upstream version 1.8.3
---
DESCRIPTION | 39 +-
MD5 | 337 +++++++--------
NAMESPACE | 3 +-
NEWS | 459 ---------------------
R/RcppExports.R | 19 +-
R/a_ply.r | 4 +-
R/aaply.r | 3 +
R/adply.r | 17 +-
R/d_ply.r | 4 +-
R/daply.r | 2 +
R/data-frame.r | 6 +-
R/ddply.r | 3 +-
R/dimensions.r | 1 -
R/dlply.r | 2 +
R/each.r | 13 +-
R/here.r | 2 +-
R/id.r | 4 +-
R/idataframe.r | 3 +-
R/indexed.r | 2 +-
R/join-all.r | 2 +-
R/join.r | 2 -
R/l_ply.r | 57 ++-
R/ldply.r | 5 +-
R/liply.r | 18 +-
R/list-to-array.r | 3 +
R/llply.r | 4 +-
R/loop_apply.R | 13 +
R/mutate.r | 2 +-
R/name-rows.r | 1 +
R/parallel.r | 15 +-
R/plyr-deprecated.r | 14 +
R/plyr.r | 2 +
R/progress-time.r | 2 +
R/progress.r | 20 +-
R/quote.r | 7 -
R/rbind-fill-matrix.r | 2 +-
R/rbind-fill.r | 10 +-
R/rdply.r | 16 +-
R/rename.r | 17 +-
R/rlply.r | 8 +-
R/splitter-a.r | 30 +-
R/summarise.r | 4 +-
R/take.r | 2 +-
R/try.r | 10 +-
R/utils-functional.r | 17 -
R/utils.r | 7 +
README.md | 2 +-
inst/tests/test-parallel.r | 31 --
inst/tests/test-quote.r | 33 --
inst/tests/test-rename.r | 39 --
man/a_ply.Rd | 62 ++-
man/aaply.Rd | 67 +--
man/adply.Rd | 76 ++--
man/alply.Rd | 59 ++-
man/amv_dim.Rd | 5 +-
man/amv_dimnames.Rd | 5 +-
man/arrange.Rd | 9 +-
man/as.data.frame.function.Rd | 18 +-
man/as.list.split.Rd | 7 +-
man/as.quoted.Rd | 11 +-
man/baseball.Rd | 44 +-
man/colwise.Rd | 12 +-
man/compact.Rd | 5 +-
man/count.Rd | 13 +-
man/create_progress_bar.Rd | 8 +-
man/d_ply.Rd | 62 +--
man/daply.Rd | 59 +--
man/ddply.Rd | 66 ++-
man/defaults.Rd | 7 +-
man/desc.Rd | 5 +-
man/dims.Rd | 5 +-
man/dlply.Rd | 54 +--
man/each.Rd | 7 +-
man/empty.Rd | 5 +-
man/eval.quoted.Rd | 8 +-
man/failwith.Rd | 9 +-
man/get-split.Rd | 9 +-
man/here.Rd | 5 +-
man/id.Rd | 7 +-
man/id_var.Rd | 3 +-
man/idata.frame.Rd | 5 +-
man/indexed_array.Rd | 7 +-
man/indexed_df.Rd | 10 +-
man/is.discrete.Rd | 5 +-
man/is.formula.Rd | 3 +-
man/isplit2.Rd | 9 +-
man/join.Rd | 24 +-
man/join.keys.Rd | 9 +-
man/join_all.Rd | 22 +-
man/l_ply.Rd | 52 +--
man/laply.Rd | 48 +--
man/ldply.Rd | 63 ++-
man/liply.Rd | 22 +-
man/list_to_array.Rd | 11 +-
man/list_to_dataframe.Rd | 12 +-
man/list_to_vector.Rd | 5 +-
man/llply.Rd | 42 +-
man/loop_apply.Rd | 11 +-
man/m_ply.Rd | 54 ++-
man/maply.Rd | 54 ++-
man/mapvalues.Rd | 13 +-
man/match_df.Rd | 11 +-
man/mdply.Rd | 59 ++-
man/mlply.Rd | 48 ++-
man/mutate.Rd | 8 +-
man/name_rows.Rd | 8 +-
man/names.quoted.Rd | 3 +-
man/nunique.Rd | 5 +-
man/ozone.Rd | 3 +-
man/plyr-deprecated.Rd | 16 +
man/plyr.Rd | 66 +--
man/print.quoted.Rd | 3 +-
man/print.split.Rd | 7 +-
man/progress_none.Rd | 3 +-
man/progress_text.Rd | 9 +-
man/progress_time.Rd | 3 +-
man/progress_tk.Rd | 10 +-
man/progress_win.Rd | 8 +-
man/quickdf.Rd | 5 +-
man/quoted.Rd | 13 +-
man/r_ply.Rd | 13 +-
man/raply.Rd | 14 +-
man/rbind.fill.Rd | 12 +-
man/rbind.fill.matrix.Rd | 8 +-
man/rdply.Rd | 21 +-
man/reduce_dim.Rd | 5 +-
man/rename.Rd | 24 +-
man/revalue.Rd | 13 +-
man/rlply.Rd | 10 +-
man/round_any.Rd | 12 +-
man/splat.Rd | 5 +-
man/split_indices.Rd | 14 +-
man/split_labels.Rd | 8 +-
man/splitter_a.Rd | 25 +-
man/splitter_d.Rd | 9 +-
man/strip_splits.Rd | 5 +-
man/summarise.Rd | 7 +-
man/take.Rd | 15 +-
man/true.Rd | 5 +-
man/try_default.Rd | 14 +-
man/tryapply.Rd | 10 +-
man/unrowname.Rd | 5 +-
man/vaggregate.Rd | 18 +-
src/RcppExports.cpp | 34 +-
src/loop-apply.cpp | 23 --
src/loop_apply.c | 25 ++
src/split-numeric.cpp | 16 +-
tests/{test-all.R => testthat.R} | 2 +-
{inst/tests => tests/testthat}/quickdf.r | 0
tests/testthat/test-arrange.r | 9 +
{inst/tests => tests/testthat}/test-array.r | 26 +-
{inst/tests => tests/testthat}/test-count.r | 16 +-
{inst/tests => tests/testthat}/test-data-frame.r | 29 +-
tests/testthat/test-debug.r | 26 ++
{inst/tests => tests/testthat}/test-empty.r | 0
tests/testthat/test-id.r | 76 ++++
{inst/tests => tests/testthat}/test-idf.r | 0
tests/testthat/test-inform.r | 53 +++
{inst/tests => tests/testthat}/test-join.r | 22 +
{inst/tests => tests/testthat}/test-list.r | 21 +-
tests/testthat/test-manip.r | 107 +++++
{inst/tests => tests/testthat}/test-mapply.r | 0
{inst/tests => tests/testthat}/test-mutate.r | 10 +-
{inst/tests => tests/testthat}/test-ninteraction.r | 8 +-
tests/testthat/test-parallel.r | 44 ++
{inst/tests => tests/testthat}/test-progress.r | 6 +-
tests/testthat/test-quote.r | 70 ++++
{inst/tests => tests/testthat}/test-rbind.matrix.r | 10 +-
{inst/tests => tests/testthat}/test-rbind.r | 23 +-
tests/testthat/test-rename.r | 113 +++++
{inst/tests => tests/testthat}/test-replicate.r | 2 +-
{inst/tests => tests/testthat}/test-revalue.r | 4 +-
{inst/tests => tests/testthat}/test-rply.r | 36 +-
{inst/tests => tests/testthat}/test-simplify-df.r | 16 +-
.../testthat}/test-split-data-frame.r | 0
.../tests => tests/testthat}/test-split-indices.r | 8 +
{inst/tests => tests/testthat}/test-split-labels.r | 0
{inst/tests => tests/testthat}/test-summarise.r | 4 +-
tests/testthat/test-utils.r | 23 ++
179 files changed, 2084 insertions(+), 1849 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index 993d2c9..7c525e6 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,27 +1,26 @@
Package: plyr
-Type: Package
-Title: Tools for splitting, applying and combining data
-Version: 1.8.1
-Author: Hadley Wickham <h.wickham at gmail.com>
-Maintainer: Hadley Wickham <h.wickham at gmail.com>
-Description: plyr is a set of tools that solves a common
- set of problems: you need to break a big problem down
- into manageable pieces, operate on each pieces and then
- put all the pieces back together. For example, you
- might want to fit a model to each spatial location or
- time point in your study, summarise data by panels or
- collapse high-dimensional arrays to simpler summary
- statistics. The development of plyr has been generously
- supported by BD (Becton Dickinson).
-URL: http://had.co.nz/plyr
-Depends: R (>= 2.11.0)
+Version: 1.8.3
+Title: Tools for Splitting, Applying and Combining Data
+Description: A set of tools that solves a common set of problems: you
+ need to break a big problem down into manageable pieces, operate on each
+ piece and then put all the pieces back together. For example, you might
+ want to fit a model to each spatial location or time point in your study,
+ summarise data by panels or collapse high-dimensional arrays to simpler
+ summary statistics. The development of 'plyr' has been generously supported
+ by 'Becton Dickinson'.
+Authors at R: person("Hadley", "Wickham", , "hadley at rstudio.com", c("aut", "cre"))
+URL: http://had.co.nz/plyr, https://github.com/hadley/plyr
+BugReports: https://github.com/hadley/plyr/issues
+Depends: R (>= 3.1.0)
Imports: Rcpp (>= 0.11.0)
LinkingTo: Rcpp
-Suggests: abind, testthat, tcltk, foreach, doMC, itertools, iterators
+Suggests: abind, testthat, tcltk, foreach, doParallel, itertools,
+ iterators
License: MIT + file LICENSE
LazyData: true
-Roxygen: list(wrap = FALSE)
-Packaged: 2014-02-26 16:06:36 UTC; hadley
NeedsCompilation: yes
+Packaged: 2015-06-11 13:04:58 UTC; hadley
+Author: Hadley Wickham [aut, cre]
+Maintainer: Hadley Wickham <hadley at rstudio.com>
Repository: CRAN
-Date/Publication: 2014-02-26 17:25:17
+Date/Publication: 2015-06-12 11:05:51
diff --git a/MD5 b/MD5
index 9a458da..bf1ec98 100644
--- a/MD5
+++ b/MD5
@@ -1,195 +1,202 @@
-14208015e2a45aa7983c4fd57b10d60a *DESCRIPTION
+36d5fb6a0ec237c345163967fc9bd932 *DESCRIPTION
7bb6b2019939096672a443d7b6e80d5b *LICENSE
-e6adf1c94f4dd5bf55de1474a328ce1c *NAMESPACE
-a72fcf3e7dee2c4d1338093ad79c984e *NEWS
-edba520097aa39d8caa24b811ac283bc *R/RcppExports.R
-b30083458b44dd0ebdb6573f81cbaf09 *R/a_ply.r
-051d8e915e9d4fd1d37baba2c8540cd3 *R/aaply.r
-7518e52d3fffabe64480674f0c0841fb *R/adply.r
+7d27e6544333941b8a6bb428284e94a5 *NAMESPACE
+b2c019f5dfd0df9d5bbbd15200be5f71 *R/RcppExports.R
+2cacb3ab0a140e444938f826a09b7a0d *R/a_ply.r
+4b2f1db5592db1334de9bd61ee98436b *R/aaply.r
+f2604fbe88644ec6f399539b4f5dbff0 *R/adply.r
effba88914db9ef403f64b4b0d00a8d5 *R/alply.r
27850e8a34d803a77059aee92fe98a51 *R/arrange.r
6eddac05a5943b98bcd29462cddc5390 *R/colwise.r
a3b498c0d8ed5f7e1a390f9efbbef4f4 *R/count.r
-f05b9167d486f77d2eaecaee67eb416f *R/d_ply.r
-fb6dcb53dca0a98cf6a1da120c2c478d *R/daply.r
-9ec2eb1767f801a2f9783af803cac212 *R/data-frame.r
+6b68e71c118e44176bc1208233cb7137 *R/d_ply.r
+0ad7db00b35f5faee233ce24b748a8a1 *R/daply.r
+50cff93340befcbf6deb04405ead23b2 *R/data-frame.r
526de3e3bf03679c79a9b4165d6cc128 *R/data.r
-6c4c8ef405dac560c9441f3a59cc1648 *R/ddply.r
+321bf16b07873b178be8484f5469af72 *R/ddply.r
201c9ac2be5dfa8fa52575e9b459bb64 *R/defaults.r
-a18f14f7e0a6f50360586504d1311227 *R/dimensions.r
-fabcd1e2c375a3861200a934b924074a *R/dlply.r
-099f05c40f96cc0e0e9bc5bb1e33cfac *R/each.r
-dcaa350d0ab003f6ad12e4d18f5eef90 *R/here.r
-acd41bddf854e33968ccb0b2fe596f0a *R/id.r
-89091436b8f027be1dda58993b1f82d8 *R/idataframe.r
+abdf36c15fa6440db800895aa3695571 *R/dimensions.r
+a7343f7e3aad4a4a11879dd842576c29 *R/dlply.r
+73c12c892419c28e8b78bf73dfccfc63 *R/each.r
+0fd02775e3776a16238525b97b99881d *R/here.r
+13cbaf54ee3454297e2b2712530e00f3 *R/id.r
+d11be448754a6f5b24301dfadefd3f05 *R/idataframe.r
fc14994abc7f86af89a188295a2dc5f5 *R/indexed-array.r
229267201ee89bc089a3b3f7c6fba5cb *R/indexed-data-frame.r
-9c4c3d5f8a5d1acfbc1d7a98ea6ee99c *R/indexed.r
-aeb3707b4a7ffae8af0e9237f3f67e72 *R/join-all.r
-f4572136e8a85fdd0bd77a2216bb557d *R/join.r
-a4a9b4bbc2be5c7f757f41cecf8bfccf *R/l_ply.r
+4e3adb71aeb565d48c87cb1592b13714 *R/indexed.r
+cd70a68dd7556c7b463c64fbb0de98f2 *R/join-all.r
+bd3b37f2d0c588b577729987a7b390b2 *R/join.r
+6e34c47b9056f5f36376eef6843d05da *R/l_ply.r
49db6bd50575429654a36aec5fca75dc *R/laply.r
-e881eda9763eaa9738d24514d2124d92 *R/ldply.r
-61a3bea3cc93368b6ac6f453a0ae3744 *R/liply.r
-aee2e6c562f11df1c6e5485e973a9b86 *R/list-to-array.r
+5c0761febd091075fd2c3c375458b9de *R/ldply.r
+996456dbd8d9748c3d7273a0b66b3cc0 *R/liply.r
+b082625367148bbede12cdeae2d9676d *R/list-to-array.r
d2d461c086c0a59c3e8bcdc2f5760086 *R/list-to-dataframe.r
0235ddca614287ca137a2a5ec80b6ecc *R/list-to-vector.r
-fe85fcdb0225eb6ac7812ff3a9aac5ba *R/llply.r
+9327d643dd06cd7024a6524be121a838 *R/llply.r
+a111fc796dbb2bb6d98e8c7a44a3cf16 *R/loop_apply.R
138f6c83d529bbf8c68f8830d7081570 *R/m_ply.r
233c43c50f214fb7b6cb4da744bda204 *R/maply.r
8c2d4fbdc639835b6a7d5fa2f01f0026 *R/match-df.r
cdf123cbd9772e88f6a1238f60b77078 *R/mdply.r
f8952eb7391ea62de7b94494f2734d23 *R/mlply.r
-fb0da67095913ebc3e7dc368e6410ca2 *R/mutate.r
-7787cd67a1bd78ff9b8169cc55015e3c *R/name-rows.r
-56cf70c7362e1f76ddf82672b8444b5c *R/parallel.r
-e535a17dfafddbb183e94b5ceb86554b *R/plyr.r
-eb8917263bad12770cd32445403be25c *R/progress-time.r
-b413617b9c819a43a15cc1b450b88cdc *R/progress.r
+9340cf2fdf5f6be08886aac2037a7274 *R/mutate.r
+f883208d0ce69464dfbe690812161a44 *R/name-rows.r
+45c5b329e5a1ab0aac2a6ccec2c2e60d *R/parallel.r
+f66e62cbef6484534c99dc3934eba248 *R/plyr-deprecated.r
+988021b688b3a21394e3ac8796297a0c *R/plyr.r
+badb88183c38a06b59b0d15b494dc519 *R/progress-time.r
+1b4dc98ab2f6f64e05a42a267af62735 *R/progress.r
87b4723fec09c203ea9c98373d87cb4b *R/quickdf.r
-fcb40695275ede3f638b9f0ff27d0d0f *R/quote.r
+641e1f551f467a54bdbb1defabd16dda *R/quote.r
d2d78e4a2a595733f0f9b15b50a36ce0 *R/r_ply.r
9280ab29ec7162e29f330717de5ee90e *R/raply.r
-9f5486ed284127abbdd22cd9ce783f4f *R/rbind-fill-matrix.r
-ac1b576c6e477408d0d1895c098c6721 *R/rbind-fill.r
-23dedcd1fbbdea0102867231c860ce1d *R/rdply.r
-483e90a4ad2aebccc73c5ddd1b32503d *R/rename.r
+5a5535287db53f7ae90e471c26d931b7 *R/rbind-fill-matrix.r
+ef73a8bd57984bfce6b86508dcc971c2 *R/rbind-fill.r
+514f68d869a789c77abde662808b7649 *R/rdply.r
+415e517a3aa9f222679efad6c5729a3c *R/rename.r
ddd658679cca81363137627bfe7edaa2 *R/revalue.r
-1eacd06285c8f96a51679bff03169133 *R/rlply.r
+a174b1efb8b3bec8dbf7256d12dad2fa *R/rlply.r
b0d8beec3c1c5cab302e9454c8b16d33 *R/round-any.r
7369a7d69027736f1e62f0f49fa8aed6 *R/splat.r
29e4abb6bc1f7561ff08c08554ccb58c *R/split.r
-c80b8aa598ab1329699f201d414a3ef6 *R/splitter-a.r
+3a1bdc96de5cdbeb96ece99f27d2567f *R/splitter-a.r
75bdf5f45ad79a232c5da028f3206489 *R/splitter-d.r
c3f4bc5baaa2be00a96fae50f235097a *R/strip-splits.r
-cb3527ae83472efb1318bbe10286df0f *R/summarise.r
-632a3d93a68172b1350d5f23151c0f0c *R/take.r
-d1c1587c3f3056b2a17c6085a1e0d8e2 *R/try.r
-d2189ca6934b505c385b70e66165e298 *R/utils-functional.r
-e7f9e2adc241a3f9ad0ab2e26e2aedb1 *R/utils.r
+9df07a1821d3b3c8698b387f037156d4 *R/summarise.r
+def748e3cbe191df41ddbf5804d48bd2 *R/take.r
+74343cc970ed6691fa2d2a0b18c3a7c5 *R/try.r
+40779d49b8ac7f779f3201fb22c5bb6b *R/utils.r
3d73325ab592dff535a8e7bd8e869967 *R/vaggregate.r
-67361b19bae482e50e4c7cba6c1eab21 *README.md
+f43b813417d6d38f110c67421bd1076f *README.md
9b2d63a08f6c4d1718642d2c904c230a *data/baseball.rda
12d6f72bbc8c97a10e7c4c235aab3ae3 *data/ozone.rda
c064ec8464bce62b7862acec50e8475b *inst/CITATION
-d564b7820ed6c9598ef0e9f39913a4dc *inst/tests/quickdf.r
-44840e515539c5a48d5dd6fc74b14d38 *inst/tests/test-array.r
-07841d0cbecdfb3efb15d1e00cb37dc0 *inst/tests/test-count.r
-4439677af6964bb0f16651e963743dc5 *inst/tests/test-data-frame.r
-570589b2d8f6a5e7a5a9292bde0255c3 *inst/tests/test-empty.r
-22fb32944156a59fb79d4b9b9185f685 *inst/tests/test-idf.r
-7ec1ca26c51cd4b3ccdafe47b7ffa2c3 *inst/tests/test-join.r
-d425059aa1aca6b0a1b89096771bbfae *inst/tests/test-list.r
-e4a2dbcd3e829d98895ac697916dbfc5 *inst/tests/test-mapply.r
-72e5df4f944d454f308efb98a475304c *inst/tests/test-mutate.r
-083da5f76a2638553a1edfed5e8d00da *inst/tests/test-ninteraction.r
-d37844e33d7c43e0968878d6c1727be7 *inst/tests/test-parallel.r
-5edbe06f3ef5ca4afebae668d5f72394 *inst/tests/test-progress.r
-af8f0160f64ccc89202dd1c6fd4255ad *inst/tests/test-quote.r
-d6275e43a3f6b046422f88c65323bc26 *inst/tests/test-rbind.matrix.r
-fd919c36a8a6db23ca1ba6bdf1830f4e *inst/tests/test-rbind.r
-0db4452cb3b1aebc91a230ec4152d8b4 *inst/tests/test-rename.r
-7d96fa52964d7d9ec5369496484455b0 *inst/tests/test-replicate.r
-d8bff3eef2ff9eb85896d7850f65b892 *inst/tests/test-revalue.r
-73bcf4bb95c4259a1a5287d09af225e5 *inst/tests/test-rply.r
-fa78b5aca1c58a0e9ca7c6dcf4a8b81d *inst/tests/test-simplify-df.r
-8333352212f7d58b1e53ce26a60afb5f *inst/tests/test-split-data-frame.r
-1d076e075a65f446945ae732ddfc50a6 *inst/tests/test-split-indices.r
-9dd79657465c4e2ab72d4209f047854b *inst/tests/test-split-labels.r
-dc9ed90dded1449345037dce24ba8c79 *inst/tests/test-summarise.r
-ac7563c48431d42b337653bc9470f0e4 *man/a_ply.Rd
-0717e4bc57b3b9c781c349efb86e342c *man/aaply.Rd
-162da28b198c3f54ada2c06ba1f10d69 *man/adply.Rd
-61fdfc2fe1e867af44fd2edb3962561a *man/alply.Rd
-c6737e21f849af791242abe7d42e3c6e *man/amv_dim.Rd
-13d927a2404446851b56c74b7c5a0974 *man/amv_dimnames.Rd
-a46d634fe4135663c2a413dbaa309891 *man/arrange.Rd
-ce3a67db1d183abb5d791fb738afa662 *man/as.data.frame.function.Rd
-31c8a413ffd907a4ae2295e78c5c41d6 *man/as.list.split.Rd
-125ea78966866bb20a3145f352db08ff *man/as.quoted.Rd
-a9d1dcc2e181e1e5dc18b55560c373aa *man/baseball.Rd
-242ded6412a6d8fb868eaa4b62dae66e *man/colwise.Rd
-d073a35a6fd27766de0c1531eda909e5 *man/compact.Rd
-525306f5b64d0a711fbc89ed736c9194 *man/count.Rd
-05e27d334ef04448d23b34ec46c60769 *man/create_progress_bar.Rd
-c044fbb3571927c57fe498d819f76511 *man/d_ply.Rd
-d4e70ed35830c41b168cf4f0b952c815 *man/daply.Rd
-2ecff2004fe134fcc39aa35db11b53db *man/ddply.Rd
-9a06d3f0de98bbf0dea7159b6896ad5b *man/defaults.Rd
-c357f0e4981cc26d10253b37d5341e71 *man/desc.Rd
-79e2db3915e958bfa14f5e8eaa68ad12 *man/dims.Rd
-1418940d42c92cf47a4ecf299f31b6e6 *man/dlply.Rd
-1d25347e06473cb692b295acd762a213 *man/each.Rd
-054cb91b58e9a156d54cdceb99481e64 *man/empty.Rd
-5ddc37a1a35ef3a3a3eabb5681aab318 *man/eval.quoted.Rd
-b41a502142050136638be5fb88e056af *man/failwith.Rd
-df3b19f0a74d194cde730c9bca65e60c *man/get-split.Rd
-e36b3ec1a2186e752541ba26ccd13fee *man/here.Rd
-86a68a1c3aa9dc9fd8dbb35eff5a66a9 *man/id.Rd
-abfd9fb1db10f420f2ef73b444c6042c *man/id_var.Rd
-af3d285c8cffdf1f1930d0c0b4415667 *man/idata.frame.Rd
-c4573fbd4cd99d964948ba464ae946cc *man/indexed_array.Rd
-db51b19ad409f316b4048714601ffcc1 *man/indexed_df.Rd
-c4c73b67ee9e610ecc639844e99c0c63 *man/is.discrete.Rd
-0ab4a96160495e032ff28400fb5cfe22 *man/is.formula.Rd
-529aec01f0fdd9485ad974dd6b270a1c *man/isplit2.Rd
-edf76d7b01d757b7ed39d793da6fb3f9 *man/join.Rd
-8e02a02baa6c4abe1385c5c8384050b0 *man/join.keys.Rd
-f4487b0ac86bd005958474da4f621394 *man/join_all.Rd
-ee498cd95cbbb9d65b3ae90cf12a3e22 *man/l_ply.Rd
-d29fcc3c1369b14433e11a7a1cc3959b *man/laply.Rd
-3aaccfa00175e832da3cdd966df12d47 *man/ldply.Rd
-b6bb7b54b4ebb9aa9d54088a1ce6dc9c *man/liply.Rd
-dc8df8de5662e83682985c5fe1b84c2a *man/list_to_array.Rd
-d59be82925f6d53f5a35fe13c913005c *man/list_to_dataframe.Rd
-6da3d504a10dfa340db784da70d781f9 *man/list_to_vector.Rd
-0f6dd3af5807166276eea60c3311bca0 *man/llply.Rd
-2125accf3842daf3d1fe69d3daa45bc4 *man/loop_apply.Rd
-4ae856a0adc3b7bcc47bba67857a3171 *man/m_ply.Rd
-7fa95148eb581bda7884b1f2c96cbc58 *man/maply.Rd
-f9d8e8f3e0c07a19390294a012b5300b *man/mapvalues.Rd
-899a76ec0843c1482c623b26608a8bc5 *man/match_df.Rd
-a9328642ff6e8ca3113a240eec9b76f9 *man/mdply.Rd
-ed8b97ad4129f1b962786dbd59a6a6ec *man/mlply.Rd
-70f471faa695d12a13e0fb5e22c137b8 *man/mutate.Rd
-61887e3a6fab5f8df3a1dd3aec0285de *man/name_rows.Rd
-4517633c15c758077114c4ca4e5c80d1 *man/names.quoted.Rd
-c0df5e2de7afaa49e55d40764db2453f *man/nunique.Rd
-26b781db290088be779a7b3057b46d71 *man/ozone.Rd
-02917b711f88ecec07d286cde41b4bb7 *man/plyr.Rd
-3e98d20eec084680efeaebebeb64477c *man/print.quoted.Rd
-689fe0eb1d86d55ada75d1be596878b6 *man/print.split.Rd
-dae967b4bd1abff5212b40685b7fb768 *man/progress_none.Rd
-2414c20ffabb82fc389dc2075440e50f *man/progress_text.Rd
-b83122c08f30caeb53fe83d45c1ddf06 *man/progress_time.Rd
-8895690a4ea7f92de532d76b7901817a *man/progress_tk.Rd
-c1fac41a81a3c2df51c1e043d223e51e *man/progress_win.Rd
-0cc3199131255ef70c39fc8c335c2eb3 *man/quickdf.Rd
-550ea88bdc7fd78f85a600f952560d03 *man/quoted.Rd
-6d888838f23da18e62235e6b024e5ad9 *man/r_ply.Rd
-3cf477584f98e23bc9a9a14ea9b6ac7d *man/raply.Rd
-171637879fb38861e5348021c4823d21 *man/rbind.fill.Rd
-afe1b642d9c6f39473b1711bf77c495f *man/rbind.fill.matrix.Rd
-6cd90c8e671d57b57299f3aa410a0722 *man/rdply.Rd
-e0b80e565d5134929fac7850ae96fb4d *man/reduce_dim.Rd
-304b67a185ac1fd5631257213074b670 *man/rename.Rd
-b2c9a28954ffb99e8a9e94b7080a93f4 *man/revalue.Rd
-3debf6b1458a5d500d723b3be7c767e4 *man/rlply.Rd
-20f64ebb7814160578db5e65215f3db1 *man/round_any.Rd
-c163527e49af38ad819b15b6a81bac99 *man/splat.Rd
-3131f9dbe17149ff748b0c092ebcc320 *man/split_indices.Rd
-b3978778315673d43609039dcaa72d40 *man/split_labels.Rd
-4c39a6c3c65a68db084edfc126959fd1 *man/splitter_a.Rd
-22ff3206e9eee2af27b00a159d838d78 *man/splitter_d.Rd
-3da1da32ffbeb8db8e5cd9ecf584f5ce *man/strip_splits.Rd
-22702c6c29248dbf8dd40d88a49e8760 *man/summarise.Rd
-8dee654011082c3e4464efbc073d75bf *man/take.Rd
-d4eb68c7800a13044ecb821c26b603c7 *man/true.Rd
-1b8e50014ced0033e54fd1862c43d7c6 *man/try_default.Rd
-eb778877be830e480848287bd1ca6cd0 *man/tryapply.Rd
-f763623701b5a5b6de951bfcd330ddf9 *man/unrowname.Rd
-31338896c22a50295e87ecf087b92eb4 *man/vaggregate.Rd
-20e536a9ddb6ea12440c2d75ae780030 *src/RcppExports.cpp
-3863469b0ab2be2e828f7c4e7a0d8f40 *src/loop-apply.cpp
-a32b01aabc1e476e7aafec401b89e6f4 *src/split-numeric.cpp
-a16ff31afc22b8d7893bfcb504d98355 *tests/test-all.R
+caf5876bb99c8c2e8122dd9db252f165 *man/a_ply.Rd
+e72dac246e26d382e434de1d4f612dec *man/aaply.Rd
+afedd2e651288a80b5bb8236a513c784 *man/adply.Rd
+ec51e7f298a0c4597e0c1b5c48bd6e01 *man/alply.Rd
+3b1249bc9a1a479e82b5ff9693ff2c94 *man/amv_dim.Rd
+6ae5223e0b33b5db448bdd2b23fcb201 *man/amv_dimnames.Rd
+010031bc6a1a3065db034cfa70728e56 *man/arrange.Rd
+d0a98d1d724a37ece6bc40686c383e20 *man/as.data.frame.function.Rd
+6b4cb393820b5757bedbd1fa76058f57 *man/as.list.split.Rd
+276259ef61c905c0fce473da39534765 *man/as.quoted.Rd
+ad978bf18a5de0479db966c6b8a6a950 *man/baseball.Rd
+bdabf7d4e155af663e00ebc1da9f26aa *man/colwise.Rd
+7ef78838916143fb90d200ff57aad888 *man/compact.Rd
+1930736a0850bc1e3a785528a05da166 *man/count.Rd
+f98627cd445404017be1c58829086356 *man/create_progress_bar.Rd
+b68a9ce2908c502496a92e715b0b77b9 *man/d_ply.Rd
+57d4318ad8d8a267307db2bbf608c319 *man/daply.Rd
+257aa384d37d3e0f4af4433057e4318f *man/ddply.Rd
+b74a45fa9c9554f843d179c37941a70b *man/defaults.Rd
+3789c3c8129fa4e91276245e5fce1e21 *man/desc.Rd
+80785e432be58dfdebed88cd370cd178 *man/dims.Rd
+e03a62ecdcde450bee8d7c6ce26cd1c4 *man/dlply.Rd
+d73378dcd563e56fd5a2d24da49ae33e *man/each.Rd
+5c752faa49755e77a217e80fbcf7f5be *man/empty.Rd
+75fefc6601949877eb269f8b819fd59c *man/eval.quoted.Rd
+06869ea759c562a42bb0a00f201ba530 *man/failwith.Rd
+690781f44d863717dc4795f03b0fef5b *man/get-split.Rd
+b19cb8666a6fee4ca2a19edac8932e6d *man/here.Rd
+8ac34ba27df7ed26903df0673d62d03c *man/id.Rd
+2804bb90e68e281cfbf329b0a18fda0d *man/id_var.Rd
+0b30ec7644b16ee5ea4b2846a553c988 *man/idata.frame.Rd
+c89b60dd956330c5cf55a139d4a1362b *man/indexed_array.Rd
+242828e535b14a54ecd16ced8c39ebc1 *man/indexed_df.Rd
+a97d04f93a64e35926fc64978f515800 *man/is.discrete.Rd
+15e9a80bcc4f46a0b3f165f92c9408ac *man/is.formula.Rd
+a99d014b5ab17bd2a66de3ab2e93c390 *man/isplit2.Rd
+398a0958d0c668f4e6dfbcd07e8fd9ac *man/join.Rd
+5ab682fc0801b3a4cd1a920fad61873a *man/join.keys.Rd
+e2e79a57461afaead13f4c0cb7992580 *man/join_all.Rd
+56400990678ef64cd3572a943736dde0 *man/l_ply.Rd
+e33c2239ab9befa79196e9e11266ae45 *man/laply.Rd
+f996a8c1f7863b59237ca08e6ac10976 *man/ldply.Rd
+377bb95354ac4b6651078bb12ce2b635 *man/liply.Rd
+a7dcf23a609466cc1478de635fd045c3 *man/list_to_array.Rd
+a43956555960f0b5a7d4b6a674d155a5 *man/list_to_dataframe.Rd
+20c7cfaf8727dacd964246d2cfee0b28 *man/list_to_vector.Rd
+0584d4b0940bc4ea30ccd54990ca03ae *man/llply.Rd
+2ed27775e4acebdd60b1527f7a452936 *man/loop_apply.Rd
+65f5e0e95f1a6276b2ed315d08147031 *man/m_ply.Rd
+f6bd855d526f8dd5df8dc6532b604816 *man/maply.Rd
+8d771e56bcc3363225828522d4273128 *man/mapvalues.Rd
+61eed27bb572fc76e11193f9a60f712d *man/match_df.Rd
+e5402f266968d3d84cd4f19ee051c68c *man/mdply.Rd
+463aaf31b4c7504d990b9d1d718c968d *man/mlply.Rd
+d0c8af9547a5ebba782b8afbf3ae3cdc *man/mutate.Rd
+5285507591bcd979dd6545105359f4e2 *man/name_rows.Rd
+7cc0a6c673a855e939d93d026a28a9e8 *man/names.quoted.Rd
+33223d90096b2527e1d3cea49087ffbd *man/nunique.Rd
+7248e7c7384044eef8b805f64ae451aa *man/ozone.Rd
+bd4ef16c4c39642f389938bd2d791e70 *man/plyr-deprecated.Rd
+aae8937364ff9974db3a24c3077d5fa8 *man/plyr.Rd
+6e9c8e5c43e7ff1d3eaa914004b63301 *man/print.quoted.Rd
+083caa3bb6be08f67794b27a1eddbbd0 *man/print.split.Rd
+06454aac6caa6718cfe1daf5a103571f *man/progress_none.Rd
+493931b9c2e9769efae7f14a94cbf397 *man/progress_text.Rd
+6c0a0341a1eb177675e5aed9566b49f9 *man/progress_time.Rd
+78ec987c14786b9292d9c7a5324761ea *man/progress_tk.Rd
+c44a03ef29c84fb7e3488787ebb90f6b *man/progress_win.Rd
+28f7603d32115974abb28b82733f1fb2 *man/quickdf.Rd
+f6d664ae71520cb31d0c148a42e64a06 *man/quoted.Rd
+566949848731086546362f16a5ac1419 *man/r_ply.Rd
+ed99abf2e90ea03186b7f307ddef3566 *man/raply.Rd
+32e1a003cab556c7c68d9c4c69be1c82 *man/rbind.fill.Rd
+d4084e4ae97a7f8d88658b0c25497a51 *man/rbind.fill.matrix.Rd
+3aabc8d9dd03a6babba5fc8b2db127f4 *man/rdply.Rd
+ded9dbc9add6e7f62448c0cb5109147a *man/reduce_dim.Rd
+07fc0a4cc6aad4f89d6c77391c0b9b02 *man/rename.Rd
+1b288c85b3c2fe7fb0b7ae06d1693e56 *man/revalue.Rd
+755fd8d851acb3d77b0cf16805e58573 *man/rlply.Rd
+b8792304a4bce43aa4281acb3f4b16c5 *man/round_any.Rd
+a594dff3b30027f36a1a6e47c77288ef *man/splat.Rd
+1cb8f3c87e6e298a19a03c89df256184 *man/split_indices.Rd
+e6371e29421010c9abc7e6e16ee9ef4f *man/split_labels.Rd
+ba1eda06bf67249f56058b9445e4a816 *man/splitter_a.Rd
+6e6b484b87c29a9d3534ff175c2ce31a *man/splitter_d.Rd
+c480006cbbf66e5d98a8d56662abd184 *man/strip_splits.Rd
+0b48a85f24a6c470f41fce52def64f97 *man/summarise.Rd
+80ba275b63f3c66642652aceb55b7dff *man/take.Rd
+e39c43fe49511debdacd49013cce44aa *man/true.Rd
+aded20eb2772aa7f1962c2c74b93b628 *man/try_default.Rd
+1ce73bea5a47f823df43f0f8d8a342bb *man/tryapply.Rd
+5a818b6a4c68dc746da9098e4ca1333c *man/unrowname.Rd
+e4978a17a149ed6951b4660f61996f6f *man/vaggregate.Rd
+023038c8fd8345b5b892162bd7c6e5c9 *src/RcppExports.cpp
+84f02af9633d0c631a97bc17a8518c59 *src/loop_apply.c
+635efc489b194a6b73c08a2e2896b36f *src/split-numeric.cpp
+3c5e14d243849a45ef414e14aa5a5184 *tests/testthat.R
+d564b7820ed6c9598ef0e9f39913a4dc *tests/testthat/quickdf.r
+276325b0874ec8b9dae723d82a2be520 *tests/testthat/test-arrange.r
+98227dadd35a099b244e08944b9ad126 *tests/testthat/test-array.r
+187e40ad2a81d6d05ff7d359b3abcdc0 *tests/testthat/test-count.r
+8e4432b2f786df04c93acbc3df0e6dd8 *tests/testthat/test-data-frame.r
+e48e8b4ea198110449eee62660bb7f87 *tests/testthat/test-debug.r
+570589b2d8f6a5e7a5a9292bde0255c3 *tests/testthat/test-empty.r
+ba14e87b8bb1b0bde96358cab3800140 *tests/testthat/test-id.r
+22fb32944156a59fb79d4b9b9185f685 *tests/testthat/test-idf.r
+8bc102a986a50c553fa40ad13edc7f39 *tests/testthat/test-inform.r
+ca184609d73e0d3d4a605e1da787716f *tests/testthat/test-join.r
+d09ac8d7646b3d6c434c50467580dc8c *tests/testthat/test-list.r
+9f2f96ae51cb9f43ba79bbff45c9f767 *tests/testthat/test-manip.r
+e4a2dbcd3e829d98895ac697916dbfc5 *tests/testthat/test-mapply.r
+0d1b884651b4e602c267673c4f86c130 *tests/testthat/test-mutate.r
+c66dedf6251001e69782f7c3f5a54349 *tests/testthat/test-ninteraction.r
+90617f3820f3ffd03fb4fb0dd4212dfc *tests/testthat/test-parallel.r
+146c98c42bcdd398d2805c35aaf83b6d *tests/testthat/test-progress.r
+173260708c547a2ebd96c2cd797c8e07 *tests/testthat/test-quote.r
+226e8fd21e0da1a8a7edfb46e81a0ebc *tests/testthat/test-rbind.matrix.r
+aee48ac33dc689320266734d9aa21aba *tests/testthat/test-rbind.r
+567571b52e4ddee6873533f2f1ed3185 *tests/testthat/test-rename.r
+30bab23a097dc350296100a63088b04e *tests/testthat/test-replicate.r
+661bace3a8cc6b8ac00d475fa88d9b9d *tests/testthat/test-revalue.r
+949976e498103b10ace8b99e01d8c38a *tests/testthat/test-rply.r
+c2a2f2887e3926a850e1923ae62689a0 *tests/testthat/test-simplify-df.r
+8333352212f7d58b1e53ce26a60afb5f *tests/testthat/test-split-data-frame.r
+d2dd8597307e5cd0b7bb7e1bae4ab331 *tests/testthat/test-split-indices.r
+9dd79657465c4e2ab72d4209f047854b *tests/testthat/test-split-labels.r
+2ccbc25d64e4f30451be4b5c019c7071 *tests/testthat/test-summarise.r
+b76073a4e32c45b1bc2cbd8911329cc7 *tests/testthat/test-utils.r
diff --git a/NAMESPACE b/NAMESPACE
index ad92b2a..99774c8 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,4 +1,4 @@
-# Generated by roxygen2 (4.0.0): do not edit by hand
+# Generated by roxygen2 (4.1.1): do not edit by hand
S3method("[",idf)
S3method("[",indexed)
@@ -102,6 +102,7 @@ export(summarise)
export(summarize)
export(take)
export(true)
+export(tryNULL)
export(try_default)
export(tryapply)
export(unrowname)
diff --git a/NEWS b/NEWS
deleted file mode 100644
index 743e746..0000000
--- a/NEWS
+++ /dev/null
@@ -1,459 +0,0 @@
-Version 1.8.1
-------------------------------------------------------------------------------
-
-* New parameter `.id` to `ldply()` and `rdply()` that specifies the name of
- the index column. (Thanks to Kirill Müller, #107, #140, #142)
-
-* New parameter `.id` to `rdply()` that specifies the name of the index
- column. (Thanks to Kirill Müller, #142)
-
-* The `.id` column in `ldply()` is generated as a factor to preserve the sort
- order. (Thanks to Kirill Müller, #137)
-
-* `rbind.fill` now silently drops NULL inputs (#138)
-
-* `rbind.fill` avoids array copying which had produced quadratic time
- complexity. `*dply` of large numbers of groups should be faster.
- (Contributed by Peter Meilstrup)
-
-* `rbind.fill` handles non-numeric matrix columns (i.e. factor arrays,
- character arrays, list arrays); also arrays with more than 2
- dimensions can be used. Dimnames of array columns are now preserved.
- (Contributed by Peter Meilstrup)
-
-* `rbind.fill(x,y)` converts factor columns of Y to character when
- columns of X are character. `join(x,y)` and `match_df(x,y)` now work
- when the key column in X is character and Y is factor. (Contributed
- by Peter Meilstrup)
-
-* Fix faulty array allocation which caused problems when using `split_indices`
- with large (> 2^24) vectors. (Fixes #131)
-
-* `list_to_array()` incorrectly determined dimensions if column of labels
- contained any missing values (#169).
-
-* `r*ply` expression is evaluated exactly `.n` times, evaluation results are
- consistent with side effects. (#158, thanks to Kirill Müller)
-
-Version 1.8
-------------------------------------------------------------------------------
-
-NEW FEATURES AND FUNCTIONS
-
-* `**ply` gain a `.inform` argument (previously only available in `llply`) - this gives more useful debugging information at the cost of some speed. (Thanks to Brian Diggs, #57)
-
-* if `.dims = TRUE` `alply`'s output gains dimensions and dimnames, similar to `apply`. Sequential indexing of a list produced by `alply` should be unaffected. (Peter Meilstrup)
-
-* `colwise`, `numcolwise` and `catcolwise` now all accept additional arguments in .... (Thanks to Stavros Macrakis, #62)
-
-* `here` makes it possible to use `**ply` + a function that uses non-standard evaluation (e.g. `summarise`, `mutate`, `subset`, `arrange`) inside a function. (Thanks to Peter Meilstrup, #3)
-
-* `join_all` recursively joins a list of data frames. (Fixes #29)
-
-* `name_rows` provides a convenient way of saving and then restoring row names so that you can preserve them if you need to. (#61)
-
-* `progress_time` (used with `.progress = "time"`) estimates the amount of time remaining before the job is completed. (Thanks to Mike Lawrence, #78)
-
-* `summarise` now works iteratively so that later columns can refer to earlier. (Thanks to Jim Hester, #44)
-
-* `take` makes it easy to subset along an arbitrary dimension.
-
-* Improved documentation thanks to patches from Tim Bates.
-
-PARALLEL PLYR
-
-* `**ply` gains a `.paropts` argument, a list of options that is passed onto `foreach` for controlling parallel computation.
-
-* `*_ply` now accepts `.parallel` argument to enable parallel processing. (Fixes #60)
-
-* Progress bars are disabled when using parallel plyr (Fixes #32)
-
-PERFORMANCE IMPROVEMENTS
-
-* `a*ply`: 25x speedup when indexing array objects, 3x speedup when indexing data frames. This should substantially reduce the overhead of using `a*ply`
-
-* `d*ply` subsetting has been considerably optimised: this will have a small impact unless you have a very large number of groups, in which case it will be considerably faster.
-
-* `idata.frame`: Subsetting immutable data frames with `[.idf` is now
- faster (Peter Meilstrup)
-
-* `quickdf` is around 20% faster
-
-* `split_indices`, which powers much internal splitting code (like `vaggregate`, `join` and `d*ply`) is about 2x faster. It was already incredible fast ~0.2s for 1,000,000 obs, so this won't have much impact on overall performance
-
-BUG FIXES
-
-* `*aply` functions now bind list mode results into a list-array (Peter Meilstrup)
-
-* `*aply` now accepts 0-dimension arrays as inputs. (#88)
-
-* `count` now works correctly for factor and Date inputs. (Fixes #130)
-
-* `*dply` now deals better with matrix results, converting them to data frames, rather than vectors. (Fixes #12)
-
-* `d*ply` will now preserve factor levels input if `drop = FALSE` (#81)
-
-* `join` works correctly when there are no common rows (Fixes #74), or when one input has no rows (Fixes #48). It also consistently orders the columns: common columns, then x cols, then y cols (Fixes #40).
-
-* `quickdf` correctly handles NA variable names. (Fixes #66. Thanks to Scott Kostyshak)
-
-* `rbind.fill` and `rbind.fill.matrix` work consistently with matrices and data frames with zero rows. Fixes #79. (Peter Meilstrup)
-
-* `rbind.fill` now stops if inputs are not data frames. (Fixes #51)
-
-* `rbind.fill` now works consistently with 0 column data frames
-
-* `round_any` now works with `POSIXct` objects, thanks to Jean-Olivier Irisson (#76)
-
-Version 1.7.1
-------------------------------------------------------------------------------
-
-* Fix bug in id, using numeric instead of integer
-
-Version 1.7
-------------------------------------------------------------------------------
-
-* `rbind.fill`: if a column contains both factors and characters (in different
- inputs), the resulting column will be coerced to character
-
-* When there are more than 2^31 distinct combinations `id`, switches to a
- slower fallback strategy using strings (inspired by `merge`) that guarantees
- correct results. This fixes problems with `join` when joining across many
- columns. (Fixes #63)
-
-* `split_indices` checks input more aggressively to prevent segfaults.
- Fixes #43.
-
-* fix small bug in `loop_apply` which lead to segfaults in certain
- circumstances. (Thanks to Pål Westermark for patch)
-
-* `itertools` and `iterators` moved to suggests from imports so that plyr now
- only depends on base R.
-
-Version 1.6
-------------------------------------------------------------------------------
-
-* documentation improved using new features of `roxygen2`
-
-* fixed namespacing issue which lead to lost labels when subsetting the
- results of `*lply`
-
-* `colwise` automatically strips off split variables.
-
-* `rlply` now correctly deals with `rlply(4, NULL)` (thanks to bug report from
- Eric Goldlust)
-
-* `rbind.fill` tries harder to keep attributes, retaining the attributes from
- the first occurrence of each column it finds. It also now works with
- variables of class `POSIXlt` and preserves the ordered status of factors.
-
-* `arrange` now works with one column data frames
-
-Version 1.5.2
-------------------------------------------------------------------------------
-
-* `d*ply` returns correct number of rows when function returns vector
-
-* fix NAMESPACE bug which was causing problems with ggplot2
-
-Version 1.5.1
-------------------------------------------------------------------------------
-
-* `rbind.fill` now treats 1d arrays in the same way as `rbind` (i.e. it turns
- them into ordinary vectors)
-
-* fix bug in rename when renaming multiple columns
-
-Version 1.5 (2011-03-02)
-------------------------------------------------------------------------------
-
-NEW FEATURES
-
-* new `strip_splits` function removes splitting variables from the data frames
- returned by `ddply`.
-
-* `rename` moved in from reshape, and rewritten.
-
-* new `match_df` function makes it easy to subset a data frame to only contain
- values matching another data frame. Inspired by
- http://stackoverflow.com/questions/4693849.
-
-BUG FIXES
-
-* `**ply` now works when passed a list of functions
-
-* `*dply` now correctly names output even when some output combinations are
- missing (NULL) (Thanks to bug report from Karl Ove Hufthammer)
-
-* `*dply` preserves the class of many more object types.
-
-* `a*ply` now correctly works with zero length margins, operating on the
- entire object (Thanks to bug report from Stavros Macrakis)
-
-* `join` now implements joins in a more SQL like way, returning all possible
- matches, not just the first one. It is still a (little) faster than merge.
- The previous behaviour is accessible with `match = "first"`.
-
-* `join` is now more symmetric so that `join(x, y, "left")` is closer to
- `join(y, x, "right")`, modulo column ordering
-
-* `named.quoted` failed when quoted expressions were longer than 50
- characters. (Thanks to bug report from Eric Goldlust)
-
-* `rbind.fill` now correctly maintains POSIXct tzone attributes and preserves
- missing factor levels
-
-* `split_labels` correctly preserves empty factor levels, which means that
- `drop = FALSE` should work in more places. Use `base::droplevels` to remove
- levels that don't occur in the data, and `drop = T` to remove combinations
- of levels that don't occur.
-
-* `vaggregate` now passes `...` to the aggregation function when working out
- the output type (thanks to bug report by Pavan Racherla)
-
-Version 1.4.1 (2011-04-05)
-------------------------------------------------------------------------------
-
-* Add citation to JSS article
-
-Version 1.4 (2011-01-03)
-------------------------------------------------------------------------------
-
-* `count` now takes an additional parameter `wt_var` which allows you to
- compute weighted sums. This is as fast, or faster than, `tapply` or `xtabs`.
-
-* Really fix bug in `names.quoted`
-
-* `.` now captures the environment in which it was evaluated. This should fix
- an esoteric class of bugs which no-one probably ever encountered, but will
- form the basis for an improved version of `ggplot2::aes`.
-
-Version 1.3.1 (2010-12-30)
-------------------------------------------------------------------------------
-
-* Fix bug in `names.quoted` that interfered with ggplot2
-
-Version 1.3 (2010-12-28)
-------------------------------------------------------------------------------
-
-NEW FEATURES
-
-* new function `mutate` that works like transform to add new columns or
- overwrite existing columns, but computes new columns iteratively so later
- transformations can use columns created by earlier transformations. (It's
- also about 10x faster) (Fixes #21)
-
-BUG FIXES
-
-* split column names are no longer coerced to valid R names.
-
-* `quickdf` now adds names if missing
-
-* `summarise` preserves variable names if explicit names not provided (Fixes
- #17)
-
-* `arrays` with names should be sorted correctly once again (also fixed a bug
- in the test case that prevented me from catching this automatically)
-
-* `m_ply` no longer possesses .parallel argument (mistakenly added)
-
-* `ldply` (and hence `adply` and `ddply`) now correctly passes on .parallel
- argument (Fixes #16)
-
-* `id` uses a better strategy for converting to integers, making it possible
- to use for cases with larger potential numbers of combinations
-
-Version 1.2.1 (2010-09-10)
-------------------------------------------------------------------------------
-
-* Fix bug in llply fast path that causes problems with ggplot2.
-
-Version 1.2 (2010-09-09)
-------------------------------------------------------------------------------
-
-NEW FEATURES
-
-* l*ply, d*ply, a*ply and m*ply all gain a .parallel argument that when TRUE,
- applies functions in parallel using a parallel backend registered with the
- foreach package:
-
- x <- seq_len(20)
- wait <- function(i) Sys.sleep(0.1)
- system.time(llply(x, wait))
- # user system elapsed
- # 0.007 0.005 2.005
-
- library(doMC)
- registerDoMC(2)
- system.time(llply(x, wait, .parallel = TRUE))
- # user system elapsed
- # 0.020 0.011 1.038
-
- This work has been generously supported by BD (Becton Dickinson).
-
-MINOR CHANGES
-
-* a*ply and m*ply gain an .expand argument that controls whether data frames
- produce a single output dimension (one element for each row), or an output
- dimension for each variable.
-
-* new vaggregate (vector aggregate) function, which is equivalent to tapply,
- but much faster (~ 10x), since it avoids copying the data.
-
-* llply: for simple lists and vectors, with no progress bar, no extra info,
- and no parallelisation, llply calls lapply directly to avoid all the
- overhead associated with those unused extra features.
-
-* llply: in serial case, for loop replaced with custom C function that takes
- about 40% less time (or about 20% less time than lapply). Note that as a
- whole, llply still has much more overhead than lapply.
-
-* round_any now lives in plyr instead of reshape
-
-BUG FIXES
-
-* list_to_array works correct even when there are missing values in the array.
- This is particularly important for daply.
-
-Version 1.1 (2010-07-19)
-------------------------------------------------------------------------------
-
-* *dply deals more gracefully with the case when all results are NULL
- (fixes #10)
-
-* *aply correctly orders output regardless of dimension names
- (fixes #11)
-
-* join gains type = "full" which preserves all x and y rows
-
-Version 1.0 (2010-07-02)
-------------------------------------------------------------------------------
-
-New functions:
-
-* arrange, a new helper method for reordering a data frame.
-* count, a version of table that returns data frames immediately and that is
- much much faster for high-dimensional data.
-* desc makes it easy to sort any vector in descending order
-* join, works like merge but can be much faster and has a somewhat simpler
- syntax drawing from SQL terminology
-* rbind.fill.matrix is like rbind.fill but works for matrices, code
- contributed by C. Beleites
-
-Speed improvements
-
-* experimental immutable data frame (idata.frame) that vastly speeds up
- subsetting - for large datasets with large numbers of groups, this can yield
- 10-fold speed ups. See examples in ?idata.frame to see how to use it.
-* rbind.fill rewritten again to increase speed and work with more data types
-* d*ply now much faster with nested groups
-
- This work has been generously supported by BD (Becton Dickinson).
-
-
-New features:
-
-* d*ply now accepts NULL for splitting variables, indicating that the data
- should not be split
-* plyr no longer exports internal functions, many of which were causing
- clashes with other packages
-* rbind.fill now works with data frame columns that are lists or matrices
-* test suite ensures that plyr behaviour is correct and will remain correct
- as I make future improvements.
-
-Bug fixes:
-
-* **ply: if zero splits, empty list(), data.frame() or logical() returned,
- as appropriate for the output type
-* **ply: leaving .fun as NULL now always returns list
- (thanks to Stavros Macrakis for the bug report)
-* a*ply: labels now respect options(stringAsFactors)
-* each: scoping bug fixed, thanks to Yasuhisa Yoshida for the bug report
-* list_to_dataframe is more consistent when processing a single data frame
-* NAs preserved in more places
-* progress bars: guaranteed to terminate even if **ply prematurely terminates
-* progress bars: misspelling gives informative warning, instead of
- uninformative error
-* splitter_d: fixed ordering bug when .drop = FALSE
-
-Version 0.1.9 (2009-06-23)
-------------------------------------------------------------------------------
-
-
-* fix bug in rbind.fill when NULLs present in list
-* improve each to recognise when all elements are numeric
-* fix labelling bug in d*ply when .drop = FALSE
-* additional methods for quoted objects
-* add summarise helper - this function is like transform, but creates a new data frame rather than reusing the old (thanks to Brendan O'Connor for the neat idea)
-
-Version 0.1.8 (2009-04-20)
-------------------------------------------------------------------------------
-
-
-* made rbind a little faster (~20%) using an idea from Richard Raubertas
-* daply now works correctly when splitting variables that contain empty factor levels
-
-Version 0.1.7 (2009-04-15)
-------------------------------------------------------------------------------
-
- * Version that rbind.fill copies attributes.
-
-Version 0.1.6 (2009-04-15)
-------------------------------------------------------------------------------
-
-
-Improvements:
-
-* all ply functions deal more elegantly when given function names: can supply a vector of function names, and name is used as label in output
-* failwith and each now work with function names as well as functions (i.e. "nrow" instead of nrow)
-* each now accepts a list of functions or a vector of function names
-* l*ply will use list names where present
-* if .inform is TRUE, error messages will give you information about where errors within your data - hopefully this will make problems easier to track down
-* d*ply no longer converts splitting variables to factors when drop = T (thanks to bug report from Charlotte Wickham)
-
-Speed-ups
-
-* massive speed ups for splitting large arrays
-* fixed typo that was causing a 50% speed penalty for d*ply
-* rewritten rbind.fill is considerably (> 4x) faster for many data frames
-* colwise about twice as fast
-
-Bug fixes:
-
-* daply: now works when the data frame is split by multiple variables
-* aaply: now works with vectors
-* ddply: first variable now varies slowest as you'd expect
-
-
-Version 0.1.5 (2009-02-23)
-------------------------------------------------------------------------------
-
-* colwise now accepts a quoted list as its second argument. This allows you to specify the names of columns to work on: colwise(mean, .(lat, long))
-* d_ply and a_ply now correctly pass ... to the function
-
-Version 0.1.4 (2008-12-12)
-------------------------------------------------------------------------------
-
- * Greatly improved speed (> 10x faster) and memory usage (50%) for splitting data frames with many combinations
- * Splitting variables containing missing values now handled consistently
-
-Version 0.1.3 (2008-11-19)
-------------------------------------------------------------------------------
-
-* Fixed problem where when splitting by a variable that contained missing values, missing combinations would be drop, and labels wouldn't match up
-
-Version 0.1.2 (2008-11-18)
-------------------------------------------------------------------------------
-
- * a*ply now works correctly with array-lists
- * drop. -> .drop
- * r*ply now works with ...
- * use inherits instead of is so method package doesn't need to be loaded
- * fix bug with using formulas
-
-Version 0.1.1 (2008-10-08)
-------------------------------------------------------------------------------
-
- * argument names now start with . (instead of ending with it) - this should prevent name clashes with arguments of the called function
- * return informative error if .fun is not a function
- * use full names in all internal calls to avoid argument name clashes
diff --git a/R/RcppExports.R b/R/RcppExports.R
index 06d58d7..220ca14 100644
--- a/R/RcppExports.R
+++ b/R/RcppExports.R
@@ -1,33 +1,20 @@
# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
-#' Loop apply
-#'
-#' An optimised version of lapply for the special case of operating on
-#' \code{seq_len(n)}
-#'
-#' @param n length of sequence
-#' @param f function to apply to each integer
-#' @param env environment in which to evaluate function
-#' @useDynLib plyr
-#' @keywords internal manip
-loop_apply <- function(n, f) {
- .Call('plyr_loop_apply', PACKAGE = 'plyr', n, f)
-}
-
#' Split indices.
#'
#' An optimised version of split for the special case of splitting row
-#' indices into groups, as used by \code{\link{splitter_d}}
+#' indices into groups, as used by \code{\link{splitter_d}}.
#'
#' @param index integer indices
-#' @param n largest integer (may not appear in index). This is hint: if
+#' @param n largest integer (may not appear in index). This is hint: if
#' the largest value of \code{group} is bigger than \code{n}, the output
#' will silently expand.
#' @useDynLib plyr
#' @keywords internal manip
#' @export
#' @examples
+#' split_indices(sample(10, 100, rep = TRUE))
#' split_indices(sample(10, 100, rep = TRUE), 10)
split_indices <- function(group, n = 0L) {
.Call('plyr_split_indices', PACKAGE = 'plyr', group, n)
diff --git a/R/a_ply.r b/R/a_ply.r
index bb9b70a..0d5fc2f 100644
--- a/R/a_ply.r
+++ b/R/a_ply.r
@@ -12,6 +12,6 @@ a_ply <- function(.data, .margins, .fun = NULL, ..., .expand = TRUE,
pieces <- splitter_a(.data, .margins, .expand)
l_ply(.data = pieces, .fun = .fun, ...,
- .progress = .progress, .print = .print, .parallel = .parallel,
- .paropts = .paropts)
+ .progress = .progress, .inform = .inform, .print = .print,
+ .parallel = .parallel, .paropts = .paropts)
}
diff --git a/R/aaply.r b/R/aaply.r
index 12a0810..5dab5dc 100644
--- a/R/aaply.r
+++ b/R/aaply.r
@@ -8,6 +8,9 @@
#' lowest dimensions. This makes \code{aaply} idempotent, so that
#' \code{aaply(input, X, identity)} is equivalent to \code{aperm(input, X)}.
#'
+#' @section Warning:Passing a data frame as first argument may lead to
+#' unexpected results, see \url{https://github.com/hadley/plyr/issues/212}.
+#'
#' @template ply
#' @template a-
#' @template -a
diff --git a/R/adply.r b/R/adply.r
index 969756a..a6efbed 100644
--- a/R/adply.r
+++ b/R/adply.r
@@ -6,13 +6,24 @@
#' @template ply
#' @template a-
#' @template -d
+#' @param .id name(s) of the index column(s).
+#' Pass \code{NULL} to avoid creation of the index column(s).
+#' Omit or pass \code{NA} to use the default names
+#' \code{"X1"}, \code{"X2"}, \ldots.
+#' Otherwise, this argument must have the same length as
+#' \code{.margins}.
#' @export
adply <- function(.data, .margins, .fun = NULL, ..., .expand = TRUE,
.progress = "none", .inform = FALSE, .parallel = FALSE,
- .paropts = NULL) {
- pieces <- splitter_a(.data, .margins, .expand)
+ .paropts = NULL, .id = NA) {
+ pieces <- splitter_a(.data, .margins, .expand, .id)
+ .id <- NA
+ if (is.null(attr(pieces, "split_labels"))) {
+ .id <- NULL
+ }
ldply(.data = pieces, .fun = .fun, ...,
.progress = .progress, .inform = .inform,
- .parallel = .parallel, .paropts = .paropts)
+ .parallel = .parallel, .paropts = .paropts,
+ .id = .id)
}
diff --git a/R/d_ply.r b/R/d_ply.r
index c303356..e4864d1 100644
--- a/R/d_ply.r
+++ b/R/d_ply.r
@@ -1,6 +1,8 @@
#' Split data frame, apply function, and discard results.
#'
-#' For each subset of a data frame, apply function and discard results
+#' For each subset of a data frame, apply function and discard results.
+#' To apply a function for each row, use \code{\link{a_ply}} with
+#' \code{.margins} set to \code{1}.
#'
#' @template ply
#' @template d-
diff --git a/R/daply.r b/R/daply.r
index 5b42b61..207d5e1 100644
--- a/R/daply.r
+++ b/R/daply.r
@@ -3,6 +3,8 @@
#' For each subset of data frame, apply function then combine results into
#' an array. \code{daply} with a function that operates column-wise is
#' similar to \code{\link{aggregate}}.
+#' To apply a function for each row, use \code{\link{aaply}} with
+#' \code{.margins} set to \code{1}.
#'
#' @template ply
#' @section Input: This function splits data frames by variables.
diff --git a/R/data-frame.r b/R/data-frame.r
index 8a8ddf0..d486283 100644
--- a/R/data-frame.r
+++ b/R/data-frame.r
@@ -1,10 +1,11 @@
#' Make a function return a data frame.
#'
#' Create a new function that returns the existing function wrapped in a
-#' data.frame
+#' data.frame with a single column, \code{value}.
#'
#' This is useful when calling \code{*dply} functions with a function that
-#' returns a vector, and you want the output in rows, rather than columns
+#' returns a vector, and you want the output in rows, rather than columns.
+#' The \code{value} column is always created, even for empty inputs.
#'
#' @keywords manip
#' @param x function to make return a data frame
@@ -14,6 +15,5 @@
#' @method as.data.frame function
#' @export
as.data.frame.function <- function(x, row.names, optional, ...) {
- name <- deparse(substitute(x))
function(...) data.frame(value = x(...))
}
diff --git a/R/ddply.r b/R/ddply.r
index dead751..bfd40bd 100644
--- a/R/ddply.r
+++ b/R/ddply.r
@@ -2,6 +2,8 @@
#'
#' For each subset of a data frame, apply function then combine results into a
#' data frame.
+#' To apply a function for each row, use \code{\link{adply}} with
+#' \code{.margins} set to \code{1}.
#'
#' @template ply
#' @template d-
@@ -10,7 +12,6 @@
#' @export
#' @examples
#' # Summarize a dataset by two variables
-#' require(plyr)
#' dfx <- data.frame(
#' group = c(rep('A', 8), rep('B', 15), rep('C', 6)),
#' sex = sample(c("M", "F"), size = 29, replace = TRUE),
diff --git a/R/dimensions.r b/R/dimensions.r
index 8b519f1..9576e18 100644
--- a/R/dimensions.r
+++ b/R/dimensions.r
@@ -48,4 +48,3 @@ reduce_dim <- function(x) {
call <- as.call(c(list(as.name("["), quote(x)), subs, list(drop = TRUE)))
eval(call)
}
-
diff --git a/R/dlply.r b/R/dlply.r
index a211b9b..b205c7f 100644
--- a/R/dlply.r
+++ b/R/dlply.r
@@ -3,6 +3,8 @@
#' For each subset of a data frame, apply function then combine results into a
#' list. \code{dlply} is similar to \code{\link{by}} except that the results
#' are returned in a different format.
+#' To apply a function for each row, use \code{\link{alply}} with
+#' \code{.margins} set to \code{1}.
#'
#' @template ply
#' @template d-
diff --git a/R/each.r b/R/each.r
index cf98c4f..826a1c9 100644
--- a/R/each.r
+++ b/R/each.r
@@ -43,18 +43,21 @@ each <- function(...) {
unames[unames == ""] <- fnames[unames == ""]
n <- length(fs)
- proto <- NULL
- result <- NULL
if (n == 1) {
# If there is only one function, things are simple. We just
# need to name the output, if appropriate.
function(x, ...) {
- res <- fs[[1]](x, ...)
+ res <- fs[[1]](x, ...) # nolint
if (length(res) == 1) names(res) <- unames
res
}
} else {
+ # nolint start
+ proto <- NULL
+ result <- NULL
+ # nolint end
+
function(x, ...) {
# For n > 1 things are a little tricky
# Construct protoype for output on first call
@@ -62,10 +65,10 @@ each <- function(...) {
result <<- vector("list", length = n)
names(result) <- unames
- for(i in 1:n) result[[i]] <- fs[[i]](x, ...)
+ for (i in 1:n) result[[i]] <- fs[[i]](x, ...) # nolint
proto <<- list_to_vector(result)
} else {
- for(i in 1:n) proto[[i]] <- fs[[i]](x, ...)
+ for (i in 1:n) proto[[i]] <- fs[[i]](x, ...) # nolint
}
proto
}
diff --git a/R/here.r b/R/here.r
index 8718b78..61ed35e 100644
--- a/R/here.r
+++ b/R/here.r
@@ -21,7 +21,7 @@
#' f2("name:")
#' # Works :)
here <- function(f) {
- call <- substitute(function(...) (f)(...), list(f = f))
+ call <- substitute(function(...) (f)(...), list(f = f)) # nolint
fun <- eval(call, parent.frame())
attr(fun, "srcref") <- srcfilecopy("<text>", deparse(call))
fun
diff --git a/R/id.r b/R/id.r
index a846b4b..9f04021 100644
--- a/R/id.r
+++ b/R/id.r
@@ -37,7 +37,7 @@ id <- function(.variables, drop = FALSE) {
# Calculate dimensions
ndistinct <- vapply(ids, attr, "n", FUN.VALUE = numeric(1),
USE.NAMES = FALSE)
-
+
n <- prod(ndistinct)
if (n > 2 ^ 31) {
# Too big for integers, have to use strings, which will be much slower :(
@@ -48,7 +48,7 @@ id <- function(.variables, drop = FALSE) {
combs <- c(1, cumprod(ndistinct[-p]))
mat <- do.call("cbind", ids)
- res <- c((mat - 1L) %*% combs + 1L)
+ res <- c((mat - 1L) %*% combs + 1L) # nolint
}
attr(res, "n") <- n
diff --git a/R/idataframe.r b/R/idataframe.r
index 361ca0f..935e02b 100644
--- a/R/idataframe.r
+++ b/R/idataframe.r
@@ -27,7 +27,8 @@ idata.frame <- function(df) {
} else {
stop("Immutable")
}
- }, list(name = name)), envir=self)
+ },
+ list(name = name)), envir=self)
})
names(self$`_getters`) <- names(df)
for (name in names(df)) {
diff --git a/R/indexed.r b/R/indexed.r
index f40bb15..3d175c6 100644
--- a/R/indexed.r
+++ b/R/indexed.r
@@ -13,7 +13,7 @@ names.indexed <- function(x) {
as.list.indexed <- function(x, ...) {
n <- length(x)
out <- vector("list", n)
- for(i in seq_len(n)) {
+ for (i in seq_len(n)) {
out[[i]] <- x[[i]]
}
names(out) <- names(x)
diff --git a/R/join-all.r b/R/join-all.r
index d52ffc8..7b8fa88 100644
--- a/R/join-all.r
+++ b/R/join-all.r
@@ -15,7 +15,7 @@ join_all <- function(dfs, by = NULL, type = "left", match = "all") {
if (length(dfs) == 1) return(dfs[[1]])
joined <- dfs[[1]]
- for(i in 2:length(dfs)) {
+ for (i in 2:length(dfs)) {
joined <- join(joined, dfs[[i]], by = by, type = type, match = match)
}
diff --git a/R/join.r b/R/join.r
index 1a77b73..b39a252 100644
--- a/R/join.r
+++ b/R/join.r
@@ -81,7 +81,6 @@ join <- function(x, y, by = NULL, type = "left", match = "all") {
stop("Duplicated key in y", call. = FALSE)
}
- new.cols <- setdiff(names(x), by)
x.match <- match(keys$y, keys$x)
x.matched <- unrowname(x[x.match, x.cols, drop = FALSE])
@@ -114,7 +113,6 @@ join <- function(x, y, by = NULL, type = "left", match = "all") {
out <- cbind(x[ids$x, , drop = FALSE], y[ids$y, y.cols, drop = FALSE])
} else if (type == "right") {
# Flip x and y, but make sure to put new columns in the right place
- new.cols <- setdiff(names(x), by)
ids <- join_ids(y, x, by, all = TRUE)
out <- cbind(
y[ids$x, by, drop = FALSE],
diff --git a/R/l_ply.r b/R/l_ply.r
index 7caf2c9..624ed43 100644
--- a/R/l_ply.r
+++ b/R/l_ply.r
@@ -6,34 +6,63 @@
#' @template l-
#' @template -_
#' @export
+#' @examples
+#' l_ply(llply(mtcars, round), table, .print = TRUE)
+#' l_ply(baseball, function(x) print(summary(x)))
l_ply <- function(.data, .fun = NULL, ..., .progress = "none", .inform = FALSE,
.print = FALSE, .parallel = FALSE, .paropts = NULL) {
if (is.character(.fun) || is.list(.fun)) .fun <- each(.fun)
if (!is.function(.fun)) stop(".fun is not a function.")
+ pieces <- as.list(.data)
+
+ n <- length(pieces)
+ if (n == 0) return(invisible())
+
+ if (.parallel && .progress != "none") {
+ message("Progress disabled when using parallel plyr")
+ .progress <- "none"
+ }
+
progress <- create_progress_bar(.progress)
- progress$init(length(.data))
+ progress$init(n)
on.exit(progress$term())
- if (.parallel) {
- if (.print) message("Printing disabled for parallel processing")
- if (.progress != "none") message("Progress disabled for parallel processing")
+ if (.parallel && .print) {
+ message("Printing disabled for parallel processing")
+ .print <- FALSE
+ }
+ do.ply <- function(i) {
+ piece <- pieces[[i]]
+
+ # Display informative error messages, if desired
+ if (.inform) {
+ res <- try(.fun(piece, ...))
+ if (inherits(res, "try-error")) {
+ piece <- paste(capture.output(print(piece)), collapse = "\n")
+ stop("with piece ", i, ": \n", piece, call. = FALSE)
+ }
+ } else {
+ res <- .fun(piece, ...)
+ }
+ if (.print) {
+ print(res)
+ }
+ progress$step()
+ }
+ if (.parallel) {
setup_parallel()
.paropts$.combine <- function(...) NULL
- fe_call <- as.call(c(list(as.name("foreach"), d = as.name(".data")),
- .paropts))
+
+ i <- seq_len(n)
+ fe_call <- as.call(c(list(quote(foreach::foreach), i = i), .paropts))
fe <- eval(fe_call)
- # Mute note about "no visible binding for d"
- d <- NULL
- fe %dopar% .fun(d, ...)
+ foreach::`%dopar%`(fe, do.ply(i))
} else {
- .data <- as.list(.data)
- for(i in seq_along(.data)) {
- x <- .fun(.data[[i]], ...)
- if (.print) print(x)
- progress$step()
+ for (i in seq_len(n)) {
+ do.ply(i)
}
}
diff --git a/R/ldply.r b/R/ldply.r
index aa41412..277a3dc 100644
--- a/R/ldply.r
+++ b/R/ldply.r
@@ -18,10 +18,11 @@ ldply <- function(.data, .fun = NULL, ..., .progress = "none", .inform = FALSE,
.progress = .progress, .inform = .inform,
.parallel = .parallel, .paropts = .paropts)
- if (is.na(.id)) {
+ if (identical(.id, NA)) {
.id <- ".id"
id_as_factor <- FALSE
- } else
+ } else {
id_as_factor <- TRUE
+ }
list_to_dataframe(res, attr(.data, "split_labels"), .id, id_as_factor)
}
diff --git a/R/liply.r b/R/liply.r
index f336d0c..103a721 100644
--- a/R/liply.r
+++ b/R/liply.r
@@ -6,22 +6,16 @@
#' than the O(n ^ 2) performance from the naive strategy of growing the list
#' each time.
#'
+#' @section Warning:Deprecated, do not use in new code.
+#' @seealso \code{\link{plyr-deprecated}}
#' @keywords manip
#' @param .iterator iterator object
#' @param .fun function to apply to each piece
#' @param ... other arguments passed on to \code{.fun}
#' @export
-#' @examples
-#' if(require("iterators")) {
-#' system.time(dlply(baseball, "id", summarise, mean_rbi = mean(rbi)))
-#' system.time({
-#' baseball_id <- isplit2(baseball, baseball$id)
-#' liply(baseball_id, summarise, mean_rbi = mean(rbi, na.rm = TRUE))
-#' })
-#' # Iterators get used up:
-#' liply(baseball_id, summarise, mean_rbi = mean(rbi, na.rm = TRUE))
-#' }
+# EXCLUDE COVERAGE START
liply <- function(.iterator, .fun = NULL, ...) {
+ .Deprecated("llply")
stopifnot(inherits(.iterator, "iter"))
if (is.null(.fun)) return(as.list(.iterator))
@@ -52,9 +46,12 @@ liply <- function(.iterator, .fun = NULL, ...) {
#' Split iterator that returns values, not indices.
#'
+#' @section Warning:Deprecated, do not use in new code.
+#' @seealso \code{\link{plyr-deprecated}}
#' @keywords internal
#' @export
isplit2 <- function (x, f, drop = FALSE, ...) {
+ .Deprecated(c("splitter_d", "splitter_a"))
it <- iterators::isplit(seq_len(nrow(x)), f, drop = drop, ...)
nextEl <- function() {
i <- iterators::nextElem(it)
@@ -62,3 +59,4 @@ isplit2 <- function (x, f, drop = FALSE, ...) {
}
structure(list(nextElem = nextEl), class = c("abstractiter", "iter"))
}
+# EXCLUDE COVERAGE END
diff --git a/R/list-to-array.r b/R/list-to-array.r
index db353a1..6c461c4 100644
--- a/R/list-to-array.r
+++ b/R/list-to-array.r
@@ -26,6 +26,9 @@ list_to_array <- function(res, labels = NULL, .drop = FALSE) {
res_dim <- amv_dim(res[[1]])
res_labels <- amv_dimnames(res[[1]])
+ if (any(vapply(res_labels, anyDuplicated, integer(1)) != 0)) {
+ warning("Duplicate names not supported.", call. = FALSE)
+ }
res_index <- expand.grid(res_labels)
res <- unlist(res, use.names = FALSE, recursive = FALSE)
diff --git a/R/llply.r b/R/llply.r
index 12b380e..90e28f7 100644
--- a/R/llply.r
+++ b/R/llply.r
@@ -69,10 +69,10 @@ llply <- function(.data, .fun = NULL, ..., .progress = "none", .inform = FALSE,
setup_parallel()
i <- seq_len(n)
- fe_call <- as.call(c(list(as.name("foreach"), i = i), .paropts))
+ fe_call <- as.call(c(list(quote(foreach::foreach), i = i), .paropts))
fe <- eval(fe_call)
- result <- fe %dopar% do.ply(i)
+ result <- foreach::`%dopar%`(fe, do.ply(i))
} else {
result <- loop_apply(n, do.ply)
}
diff --git a/R/loop_apply.R b/R/loop_apply.R
new file mode 100644
index 0000000..9905326
--- /dev/null
+++ b/R/loop_apply.R
@@ -0,0 +1,13 @@
+#' Loop apply
+#'
+#' An optimised version of lapply for the special case of operating on
+#' \code{seq_len(n)}
+#'
+#' @param n length of sequence
+#' @param f function to apply to each integer
+#' @param env environment in which to evaluate function
+#' @useDynLib plyr
+#' @keywords internal manip
+loop_apply <- function(n, f, env = parent.frame()) {
+ .Call("loop_apply", as.integer(n), f, env)
+}
diff --git a/R/mutate.r b/R/mutate.r
index eb896d2..98676f1 100644
--- a/R/mutate.r
+++ b/R/mutate.r
@@ -31,7 +31,7 @@ mutate <- function(.data, ...) {
cols <- as.list(substitute(list(...))[-1])
cols <- cols[names(cols) != ""] # Silently drop unnamed columns
- for(col in names(cols)) {
+ for (col in names(cols)) {
.data[[col]] <- eval(cols[[col]], .data, parent.frame())
}
.data
diff --git a/R/name-rows.r b/R/name-rows.r
index 1cc8661..93ddb96 100644
--- a/R/name-rows.r
+++ b/R/name-rows.r
@@ -8,6 +8,7 @@
#' @param df a data.frame, with either \code{rownames}, or a column called
#' \code{.rownames}.
#' @export
+#' @keywords manip
#' @examples
#' name_rows(mtcars)
#' name_rows(name_rows(mtcars))
diff --git a/R/parallel.r b/R/parallel.r
index 2e738ea..2a531fd 100644
--- a/R/parallel.r
+++ b/R/parallel.r
@@ -1,16 +1,13 @@
setup_parallel <- function() {
- if (!require("foreach")) {
+ if (!requireNamespace("foreach", quietly = TRUE)) {
+ # EXCLUDE COVERAGE START
stop("foreach package required for parallel plyr operation",
call. = FALSE)
+ # EXCLUDE COVERAGE END
}
- if (getDoParWorkers() == 1) {
+ if (foreach::getDoParWorkers() == 1) {
+ # EXCLUDE COVERAGE START
warning("No parallel backend registered", call. = TRUE)
+ # EXCLUDE COVERAGE END
}
}
-
-parallel_fe <- function(n, options) {
- i <- seq_len(n)
- fe_call <- as.call(c(list(as.name("foreach"), i = i), options))
-
- eval(fe_call)
-}
diff --git a/R/plyr-deprecated.r b/R/plyr-deprecated.r
new file mode 100644
index 0000000..7094a9e
--- /dev/null
+++ b/R/plyr-deprecated.r
@@ -0,0 +1,14 @@
+#' Deprecated Functions in Package plyr
+#'
+#' These functions are provided for compatibility with older versions of
+#' \code{plyr} only, and may be defunct as soon as the next release.
+#'
+#' \itemize{
+#' \item \code{\link{liply}}
+#' \item \code{\link{isplit2}}
+#' }
+#'
+#' @name plyr-deprecated
+# EXCLUDE COVERAGE START
+NULL
+# EXCLUDE COVERAGE END
diff --git a/R/plyr.r b/R/plyr.r
index a161ca2..f881252 100644
--- a/R/plyr.r
+++ b/R/plyr.r
@@ -62,9 +62,11 @@
#' @docType package
#' @importFrom Rcpp sourceCpp
#' @name plyr
+# EXCLUDE COVERAGE START
NULL
.onUnload <- function (libpath) {
library.dynam.unload("plyr", libpath)
}
+# EXCLUDE COVERAGE END
diff --git a/R/progress-time.r b/R/progress-time.r
index 615beb0..57feaeb 100644
--- a/R/progress-time.r
+++ b/R/progress-time.r
@@ -24,8 +24,10 @@ progress_time <- function() {
}
txtTimerBar <- function(n = 1) {
+ # nolint start
start <- .last_update_time <- proc.time()[3]
times <- numeric(n)
+ # nolint end
value <- NULL
killed <- FALSE
diff --git a/R/progress.r b/R/progress.r
index 0e60213..d38b9e1 100644
--- a/R/progress.r
+++ b/R/progress.r
@@ -62,9 +62,9 @@ create_progress_bar <- function(name = "none", ...) {
#' l_ply(1:100, identity, .progress = "none")
progress_none <- function() {
list(
- init = function(x) {},
- step = function() {},
- term = function() {}
+ init = function(x) NULL,
+ step = function() NULL,
+ term = function() NULL
)
}
@@ -119,18 +119,18 @@ progress_text <- function(style = 3, ...) {
#' l_ply(1:100, identity, .progress = progress_tk(label=""))
#' }
progress_tk <- function(title = "plyr progress", label = "Working...", ...) {
- stopifnot(require("tcltk", quietly = TRUE))
+ stopifnot(requireNamespace("tcltk", quietly = TRUE))
n <- 0
tk <- NULL
list(
init = function(x) {
- tk <<- tkProgressBar(max = x, title = title, label = label, ...)
- setTkProgressBar(tk, 0)
+ tk <<- tcltk::tkProgressBar(max = x, title = title, label = label, ...)
+ tcltk::setTkProgressBar(tk, 0)
},
step = function() {
n <<- n + 1
- setTkProgressBar(tk, n)
+ tcltk::setTkProgressBar(tk, n)
},
term = function() close(tk)
)
@@ -158,12 +158,12 @@ progress_win <- function(title = "plyr progress", ...) {
list(
init = function(x) {
- win <<- winProgressBar(max = x, title = title, ...)
- setWinProgressBar(win, 0)
+ win <<- winProgressBar(max = x, title = title, ...) # nolint
+ setWinProgressBar(win, 0) # nolint
},
step = function() {
n <<- n + 1
- setWinProgressBar(win, n)
+ setWinProgressBar(win, n) # nolint
},
term = function() close(win)
)
diff --git a/R/quote.r b/R/quote.r
index dce3ed2..1506e25 100644
--- a/R/quote.r
+++ b/R/quote.r
@@ -192,10 +192,3 @@ c.quoted <- function(..., recursive = FALSE) {
"[.quoted" <- function(x, i, ...) {
structure(NextMethod("["), env = attr(x, "env"), class = "quoted")
}
-
-#' Is a formula?
-#' Checks if argument is a formula
-#'
-#' @keywords internal
-#' @export
-is.formula <- function(x) inherits(x, "formula")
diff --git a/R/rbind-fill-matrix.r b/R/rbind-fill-matrix.r
index 85a58fa..f823a39 100644
--- a/R/rbind-fill-matrix.r
+++ b/R/rbind-fill-matrix.r
@@ -69,7 +69,7 @@ rbind.fill.matrix <- function(...) {
pos <- matrix(c(cumsum(rows) - rows + 1, rows), ncol = 2)
## fill in the new matrix
- for(i in seq_along(rows)) {
+ for (i in seq_along(rows)) {
rng <- seq(pos[i, 1], length = pos[i, 2])
output[rng, lcols[[i]]] <- matrices[[i]]
}
diff --git a/R/rbind-fill.r b/R/rbind-fill.r
index 6cf2597..bf38c85 100644
--- a/R/rbind-fill.r
+++ b/R/rbind-fill.r
@@ -62,12 +62,12 @@ rbind.fill <- function(...) {
pos <- matrix(c(cumsum(rows) - rows + 1, rows), ncol = 2)
# Copy inputs into output
- for(i in seq_along(rows)) {
+ for (i in seq_along(rows)) {
rng <- seq(pos[i, 1], length = pos[i, 2])
df <- dfs[[i]]
- for(var in names(df)) {
- setters[[var]](rng, df[[var]])
+ for (var in names(df)) {
+ setters[[var]](rng, df[[var]]) # nolint
}
}
@@ -83,9 +83,9 @@ output_template <- function(dfs, nrows) {
seen <- rep(FALSE, length(output))
names(seen) <- vars
- for(df in dfs) {
+ for (df in dfs) {
matching <- intersect(names(df), vars[!seen])
- for(var in matching) {
+ for (var in matching) {
output[[var]] <- allocate_column(df[[var]], nrows, dfs, var)
}
diff --git a/R/rdply.r b/R/rdply.r
index 7f4525b..4e8ba10 100644
--- a/R/rdply.r
+++ b/R/rdply.r
@@ -1,6 +1,6 @@
#' Replicate expression and return results in a data frame.
#'
-#' Evalulate expression n times then combine results into a data frame
+#' Evaluate expression n times then combine results into a data frame
#'
#' This function runs an expression multiple times, and combines the result into
#' a data frame. If there are no results, then this function returns a data
@@ -16,8 +16,7 @@
#' \code{\link{create_progress_bar}}
#' @param .id name of the index column. Pass \code{NULL} to avoid creation of
#' the index column. For compatibility, omit this argument or pass \code{NA}
-#' to avoid converting the index column to a factor; in this case, \code{".n"}
-#' is used as colum name..
+#' to use \code{".n"} as column name.
#' @return a data frame
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for Data
@@ -31,8 +30,13 @@ rdply <- function(.n, .expr, .progress = "none", .id = NA) {
res <- .rlply_worker(.n, .progress,
eval.parent(substitute(function() .expr)))
names(res) <- seq_len(.n)
- labels <- data.frame(.n = seq_len(.n))
- if (!is.na(.id))
- names(labels) <- .id
+ if (is.null(.id)) {
+ labels <- NULL
+ } else {
+ labels <- data.frame(.n = seq_len(.n))
+ if (!is.na(.id)) {
+ names(labels) <- .id
+ }
+ }
list_to_dataframe(res, labels)
}
diff --git a/R/rename.r b/R/rename.r
index a200538..f8da0ae 100644
--- a/R/rename.r
+++ b/R/rename.r
@@ -5,6 +5,8 @@
#' old names as names.
#' @param warn_missing print a message if any of the old names are
#' not actually present in \code{x}.
+#' @param warn_duplicated print a message if any name appears more
+#' than once in \code{x} after the operation.
#' Note: x is not altered: To save the result, you need to copy the returned
#' data into a variable.
#' @export
@@ -12,11 +14,22 @@
#' @examples
#' x <- c("a" = 1, "b" = 2, d = 3, 4)
#' # Rename column d to "c", updating the variable "x" with the result
-#' x <- rename(x, replace=c("d" = "c"))
+#' x <- rename(x, replace = c("d" = "c"))
#' x
#' # Rename column "disp" to "displacement"
#' rename(mtcars, c("disp" = "displacement"))
-rename <- function(x, replace, warn_missing = TRUE) {
+rename <- function(x, replace, warn_missing = TRUE, warn_duplicated = TRUE ) {
+
+ # This line does the real work of `rename()`.
names(x) <- revalue(names(x), replace, warn_missing = warn_missing)
+
+ # Check if any names are duplicated.
+ duplicated_names <- names(x)[duplicated(names(x))]
+ if (warn_duplicated && (length(duplicated_names) > 0L)) {
+ duplicated_names_message <- paste0("`", duplicated_names, "`", collapse=", ")
+ warning("The plyr::rename operation has created duplicates for the ",
+ "following name(s): (", duplicated_names_message, ")",
+ call. = FALSE)
+ }
x
}
diff --git a/R/rlply.r b/R/rlply.r
index a2a3bfc..e9d3237 100644
--- a/R/rlply.r
+++ b/R/rlply.r
@@ -39,7 +39,9 @@ rlply <- function(.n, .expr, .progress = "none") {
on.exit(progress$term())
if (.print) {
- wrap <- function(f) function() { print(f()) }
+ wrap <- function(f) function() {
+ print(f())
+ }
} else {
wrap <- identity
}
@@ -63,7 +65,7 @@ rlply <- function(.n, .expr, .progress = "none") {
wrap(function() fun$val)()
progress$step()
- for(i in seq.int(from = 2L, length.out = .n - 1L)) {
+ for (i in seq.int(from = 2L, length.out = .n - 1L)) {
f()
progress$step()
}
@@ -74,7 +76,7 @@ rlply <- function(.n, .expr, .progress = "none") {
result[1L] <- list(wrap(function() fun$val)())
progress$step()
- for(i in seq.int(from = 2L, length.out = .n - 1L)) {
+ for (i in seq.int(from = 2L, length.out = .n - 1L)) {
result[i] <- list(f())
progress$step()
}
diff --git a/R/splitter-a.r b/R/splitter-a.r
index 5b2f874..76aa883 100644
--- a/R/splitter-a.r
+++ b/R/splitter-a.r
@@ -19,6 +19,12 @@
#' @param .expand if splitting a dataframe by row, should output be 1d
#' (expand = FALSE), with an element for each row; or nd (expand = TRUE),
#' with a dimension for each variable.
+#' @param .id names of the split label.
+#' Pass \code{NULL} to avoid creation of split labels.
+#' Omit or pass \code{NA} to use the default names
+#' \code{"X1"}, \code{"X2"}, \ldots.
+#' Otherwise, this argument must have the same length as
+#' \code{.margins}.
#' @return a list of lower-d slices, with attributes that record split details
#' @family splitter functions
#' @keywords internal
@@ -29,9 +35,20 @@
#' plyr:::splitter_a(ozone, 2)
#' plyr:::splitter_a(ozone, 3)
#' plyr:::splitter_a(ozone, 1:2)
-splitter_a <- function(data, .margins = 1L, .expand = TRUE) {
+splitter_a <- function(data, .margins = 1L, .expand = TRUE, .id = NA) {
.margins <- as.integer(.margins)
+ if (!is.null(.id)) {
+ if (any(is.na(.id))) {
+ .id <- paste("X", seq_along(.margins), sep="")
+ } else {
+ if (length(.id) != length(.margins)) {
+ stop(".id argument must be of length ", length(.margins), " (=number of margins)")
+ }
+ .id <- as.character(.id)
+ }
+ }
+
if (length(.margins) == 0) {
return(list(data))
}
@@ -42,7 +59,8 @@ splitter_a <- function(data, .margins = 1L, .expand = TRUE) {
dimensions[-.margins] <- list("")
indices <- expand.grid(dimensions, KEEP.OUT.ATTRS = FALSE,
stringsAsFactors = FALSE)
- names(indices) <- paste("X", 1:ncol(indices), sep="")
+
+ names(indices) <- paste("X", seq_len(ncol(indices)), sep="")
# Ensure indices are ordered in the way in which they should appear in the
# output - last margin varies fastest
@@ -58,6 +76,9 @@ splitter_a <- function(data, .margins = 1L, .expand = TRUE) {
dnames <- list(seq_len(nrow(data)), names(data))
} else {
dnames <- amv_dimnames(data)
+ if (any(vapply(dnames, anyDuplicated, integer(1)) != 0)) {
+ warning("Duplicate names not supported.", call. = FALSE)
+ }
dnames <- lapply(dnames, function(x) factor(x, levels = x))
}
@@ -67,8 +88,11 @@ splitter_a <- function(data, .margins = 1L, .expand = TRUE) {
if (!is.null(names(dnames))) {
names(split_labels) <- names(dnames)[.margins]
} else {
- names(split_labels) <- paste("X", seq_along(.margins), sep = "")
+ names(split_labels) <- .id
}
+
+ if (is.null(.id))
+ split_labels <- NULL
}
structure(
diff --git a/R/summarise.r b/R/summarise.r
index d6f0962..e3ea8f8 100644
--- a/R/summarise.r
+++ b/R/summarise.r
@@ -10,7 +10,7 @@
#' @keywords manip
#' @aliases summarise summarize
#' @export summarise summarize
-#' @note Be careful when using existing variable names; the corresponding
+#' @note Be careful when using existing variable names; the corresponding
#' columns will be immediately updated with the new data and this can affect
#' subsequent operations referring to those variables.
#' @examples
@@ -35,7 +35,7 @@ summarise <- function(.data, ...) {
missing_names <- names(cols) == ""
}
if (any(missing_names)) {
- names <- unname(unlist(lapply(match.call(expand.dots = FALSE)$`...`, deparse)))
+ names <- unname(unlist(lapply(match.call(expand.dots = FALSE)$`...`, deparse))) # nolint
names(cols)[missing_names] <- names[missing_names]
}
.data <- as.list(.data)
diff --git a/R/take.r b/R/take.r
index 0757913..f33aa34 100644
--- a/R/take.r
+++ b/R/take.r
@@ -6,6 +6,7 @@
#' @param drop should the dimensions of the array be simplified? Defaults
#' to \code{FALSE} which is the opposite of the useful R default.
#' @export
+#' @keywords manip
#' @examples
#' x <- array(seq_len(3 * 4 * 5), c(3, 4, 5))
#' take(x, 3, 1)
@@ -22,4 +23,3 @@ take <- function(x, along, indices, drop = FALSE) {
eval(as.call(c(as.name("["), as.name("x"), index, drop = drop)))
}
-
diff --git a/R/try.r b/R/try.r
index 34f531f..d074ce5 100644
--- a/R/try.r
+++ b/R/try.r
@@ -28,31 +28,35 @@ failwith <- function(default = NULL, f, quiet = FALSE) {
#' Try, with default in case of error.
#'
#' \code{try_default} wraps try so that it returns a default value in the case of error.
-#'
#' \code{tryNULL} provides a useful special case when dealing with lists.
#'
#' @param expr expression to try
#' @param default default value in case of error
#' @param quiet should errors be printed (TRUE) or ignored (FALSE, default)
-#' @aliases try_default tryNULL
#' @export
#' @keywords internal
#' @seealso \code{\link{tryapply}}
try_default <- function(expr, default, quiet = FALSE) {
result <- default
if (quiet) {
- tryCatch(result <- expr, error = function(e) {})
+ tryCatch(result <- expr, error = function(e) NULL)
} else {
try(result <- expr)
}
result
}
+
+#' @rdname try_default
+#' @export
tryNULL <- function(expr) try_default(expr, NULL, quiet = TRUE)
#' Apply with built in try.
#' Uses compact, lapply and tryNULL
#'
+#' @param list list to apply function \code{f} on
+#' @param f function
+#' @param ... further arguments to \code{f}
#' @keywords internal
#' @export
tryapply <- function(list, fun, ...) {
diff --git a/R/utils-functional.r b/R/utils-functional.r
deleted file mode 100644
index 13c9253..0000000
--- a/R/utils-functional.r
+++ /dev/null
@@ -1,17 +0,0 @@
-# f <- function(...) {
-# dots()
-# }
-
-# g <- function() {
-# f <- function(x, y, ...) {
-# dots()
-# }
-# f(x = 1, y = 2, z = 3)
-# }
-dots <- function() {
- call <- sys.call(-1)
- def <- eval(call[[1]], parent.frame(2))
- match.call(def, call, expand.dots = FALSE)$`...`
-}
-
-
diff --git a/R/utils.r b/R/utils.r
index e75f838..0979b56 100644
--- a/R/utils.r
+++ b/R/utils.r
@@ -66,6 +66,13 @@ empty <- function(df) {
(is.null(df) || nrow(df) == 0 || ncol(df) == 0)
}
+#' Is a formula?
+#' Checks if argument is a formula
+#'
+#' @keywords internal
+#' @export
+is.formula <- function(x) inherits(x, "formula")
+
"%||%" <- function(a, b) if (is.null(a)) b else a
.matrix_to_df <- function(.data) {
diff --git a/README.md b/README.md
index 682866d..c79d97c 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![Build Status](https://travis-ci.org/hadley/plyr.png?branch=master)](https://travis-ci.org/hadley/plyr)
+[![Build Status](https://travis-ci.org/hadley/plyr.png?branch=master)](https://travis-ci.org/hadley/plyr) [![Coverage Status](https://coveralls.io/repos/hadley/plyr/badge.svg?branch=master)](https://coveralls.io/r/hadley/plyr?branch=master)
# plyr
diff --git a/inst/tests/test-parallel.r b/inst/tests/test-parallel.r
deleted file mode 100644
index 7057cfc..0000000
--- a/inst/tests/test-parallel.r
+++ /dev/null
@@ -1,31 +0,0 @@
-context("Parallel")
-
-if (require("doMC", quietly = TRUE)) {
- registerDoMC(2)
-
- if (identical(Sys.getenv("NOT_CRAN"), "true")) {
- test_that("l_ply respects .parallel", {
- expect_that(
- l_ply(c(0.1, 0.1), Sys.sleep, .parallel = TRUE),
- takes_less_than(0.15))
- })
- }
-
- test_that("l_ply + .parallel complains about invalid arguments", {
- expect_message(
- l_ply(1:10, force, .parallel = TRUE, .print = TRUE),
- "Printing disabled")
- expect_message(
- l_ply(1:10, force, .parallel = TRUE, .progress = "text"),
- "Progress disabled")
- })
-
- test_that(".paropts passes options to foreach", {
- combine <- function(a, b) NULL
- x <- llply(1:10, identity, .parallel = TRUE,
- .paropts = list(.combine = combine))
- expect_equal(x, NULL)
- })
-
- registerDoMC(1)
-}
diff --git a/inst/tests/test-quote.r b/inst/tests/test-quote.r
deleted file mode 100644
index b7611e8..0000000
--- a/inst/tests/test-quote.r
+++ /dev/null
@@ -1,33 +0,0 @@
-context("Quoting")
-
-test_that("quoting captures current environment", {
- x <- .(a, b, c)
- expect_that(attr(x, "env"), is_identical_to(environment()))
-
- x <- as.quoted(c("a", "b", "c"))
- expect_that(attr(x, "env"), is_identical_to(environment()))
-})
-
-test_that("evaluation takes place in correct environment", {
- a <- 2
- x <- local({
- a <- 1
- .(a)
- })
-
- expect_that(eval.quoted(x)$a, equals(1))
-
- df <- data.frame(x = 1:10)
- x <- local({
- a <- 1
- .(x * a)
- })
- expect_that(eval.quoted(x, df)[[1]], equals(1:10))
-
-})
-
-test_that("names work for long expressions", {
- q <- .(foo = barjasdfgjadhfgjsdhfgusdhfgusheguisdhguioahsrofasdgsdfgsdfg +
- dfgafgasdfgsdfgsdfgsdfgsdfgsdfgsdfg)
- expect_that(names(q), equals("foo"))
-})
diff --git a/inst/tests/test-rename.r b/inst/tests/test-rename.r
deleted file mode 100644
index 89a5047..0000000
--- a/inst/tests/test-rename.r
+++ /dev/null
@@ -1,39 +0,0 @@
-context("Rename")
-
-test_that("No match leaves names unchanged", {
- x <- c(a = 1, b = 2, c = 3, 4)
- y <- rename(x, c(d = "e"), warn_missing = FALSE)
-
- expect_equal(names(x), names(y))
-})
-
-test_that("Missing old values result in message", {
- # This is the same rename operation as above, but should give a message
- x <- c(a = 1, b = 2, c = 3, 4)
- expect_message(rename(x, c(d = "e")))
-})
-
-test_that("Single name match makes change", {
- x <- c(a = 1, b = 2)
- y <- rename(x, c(b = "c"))
-
- expect_equal(names(y), c("a", "c"))
-})
-
-test_that("Multiple names correctly changed", {
- x <- c(a = 1, b = 2, c = 3)
- y <- rename(x, c("c" = "f", "b" = "e", "a" = "d"))
-
- expect_equal(names(y), c("d", "e", "f"))
-})
-
-test_that("Empty vectors and lists", {
- expect_identical(rename(character(), c("c" = "f"), warn_missing = FALSE), character())
- expect_identical(rename(list(), c("c" = "f"), warn_missing = FALSE), list())
-})
-
-test_that("Renaming lists", {
- x <- list(a = 1, b = 2, c = 3)
- y <- rename(x, c("c" = "f", "b" = "e", "a" = "d"))
- expect_identical(y, list(d = 1, e = 2, f = 3))
-})
diff --git a/man/a_ply.Rd b/man/a_ply.Rd
index 762b21f..aecfb72 100644
--- a/man/a_ply.Rd
+++ b/man/a_ply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/a_ply.r
\name{a_ply}
\alias{a_ply}
\title{Split array, apply function, and discard results.}
@@ -8,42 +9,38 @@ a_ply(.data, .margins, .fun = NULL, ..., .expand = TRUE,
.parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{matrix, array or data frame to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.margins}{a vector giving the subscripts to split up \code{data} by.
+1 splits up by rows, 2 by columns and c(1,2) by rows and columns, and so
+on for higher dimensions}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.fun}{function to apply to each piece}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.expand}{if \code{.data} is a data frame, should output be 1d (expand
+ = FALSE), with an element for each row; or nd (expand = TRUE), with a
+dimension for each variable.}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.data}{matrix, array or data frame to be processed}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.margins}{a vector giving the subscripts to split
- up \code{data} by. 1 splits up by rows, 2 by columns and
- c(1,2) by rows and columns, and so on for higher
- dimensions}
+\item{.print}{automatically print each result? (default: \code{FALSE})}
- \item{.expand}{if \code{.data} is a data frame, should
- output be 1d (expand = FALSE), with an element for each
- row; or nd (expand = TRUE), with a dimension for each
- variable.}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.print}{automatically print each result? (default:
- \code{FALSE})}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
Nothing
@@ -52,14 +49,15 @@ Nothing
For each slice of an array, apply function and discard results
}
\section{Input}{
- This function splits matrices, arrays and data frames by
+ This function splits matrices, arrays and data frames by
dimensions
}
\section{Output}{
- All output is discarded. This is useful for functions
- that you are calling purely for their side effects like
- displaying plots or saving output.
+
+ All output is discarded. This is useful for functions that you are
+ calling purely for their side effects like displaying plots or
+ saving output.
}
\references{
Hadley Wickham (2011). The Split-Apply-Combine Strategy
diff --git a/man/aaply.Rd b/man/aaply.Rd
index dab029b..d960954 100644
--- a/man/aaply.Rd
+++ b/man/aaply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/aaply.r
\name{aaply}
\alias{aaply}
\title{Split array, apply function, and return results in an array.}
@@ -8,43 +9,39 @@ aaply(.data, .margins, .fun = NULL, ..., .expand = TRUE,
.paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{matrix, array or data frame to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.margins}{a vector giving the subscripts to split up \code{data} by.
+1 splits up by rows, 2 by columns and c(1,2) by rows and columns, and so
+on for higher dimensions}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.fun}{function to apply to each piece}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.expand}{if \code{.data} is a data frame, should output be 1d (expand
+ = FALSE), with an element for each row; or nd (expand = TRUE), with a
+dimension for each variable.}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.data}{matrix, array or data frame to be processed}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.margins}{a vector giving the subscripts to split
- up \code{data} by. 1 splits up by rows, 2 by columns and
- c(1,2) by rows and columns, and so on for higher
- dimensions}
+\item{.drop}{should extra dimensions of length 1 in the output be
+dropped, simplifying the output. Defaults to \code{TRUE}}
- \item{.expand}{if \code{.data} is a data frame, should
- output be 1d (expand = FALSE), with an element for each
- row; or nd (expand = TRUE), with a dimension for each
- variable.}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.drop}{should extra dimensions of length 1 in the
- output be dropped, simplifying the output. Defaults to
- \code{TRUE}}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
if results are atomic with same type and dimensionality, a
@@ -61,14 +58,20 @@ those dimensions are added on to the highest dimensions, rather than the
lowest dimensions. This makes \code{aaply} idempotent, so that
\code{aaply(input, X, identity)} is equivalent to \code{aperm(input, X)}.
}
+\section{Warning}{
+Passing a data frame as first argument may lead to
+unexpected results, see \url{https://github.com/hadley/plyr/issues/212}.
+}
+
\section{Input}{
- This function splits matrices, arrays and data frames by
+ This function splits matrices, arrays and data frames by
dimensions
}
\section{Output}{
- If there are no results, then this function will return a
- vector of length 0 (\code{vector()}).
+
+ If there are no results, then this function will return a vector of
+ length 0 (\code{vector()}).
}
\examples{
dim(ozone)
diff --git a/man/adply.Rd b/man/adply.Rd
index 59d73f5..c9f1794 100644
--- a/man/adply.Rd
+++ b/man/adply.Rd
@@ -1,46 +1,51 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/adply.r
\name{adply}
\alias{adply}
\title{Split array, apply function, and return results in a data frame.}
\usage{
adply(.data, .margins, .fun = NULL, ..., .expand = TRUE,
.progress = "none", .inform = FALSE, .parallel = FALSE,
- .paropts = NULL)
+ .paropts = NULL, .id = NA)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{matrix, array or data frame to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.margins}{a vector giving the subscripts to split up \code{data} by.
+1 splits up by rows, 2 by columns and c(1,2) by rows and columns, and so
+on for higher dimensions}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.fun}{function to apply to each piece}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.expand}{if \code{.data} is a data frame, should output be 1d (expand
+ = FALSE), with an element for each row; or nd (expand = TRUE), with a
+dimension for each variable.}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.data}{matrix, array or data frame to be processed}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.margins}{a vector giving the subscripts to split
- up \code{data} by. 1 splits up by rows, 2 by columns and
- c(1,2) by rows and columns, and so on for higher
- dimensions}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.expand}{if \code{.data} is a data frame, should
- output be 1d (expand = FALSE), with an element for each
- row; or nd (expand = TRUE), with a dimension for each
- variable.}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
+
+\item{.id}{name(s) of the index column(s).
+Pass \code{NULL} to avoid creation of the index column(s).
+Omit or pass \code{NA} to use the default names
+\code{"X1"}, \code{"X2"}, \ldots.
+Otherwise, this argument must have the same length as
+\code{.margins}.}
}
\value{
A data frame, as described in the output section.
@@ -50,21 +55,20 @@ For each slice of an array, apply function then combine results into a data
frame.
}
\section{Input}{
- This function splits matrices, arrays and data frames by
+ This function splits matrices, arrays and data frames by
dimensions
}
\section{Output}{
- The most unambiguous behaviour is achieved when
- \code{.fun} returns a data frame - in that case pieces
- will be combined with \code{\link{rbind.fill}}. If
- \code{.fun} returns an atomic vector of fixed length, it
- will be \code{rbind}ed together and converted to a data
+
+ The most unambiguous behaviour is achieved when \code{.fun} returns a
+ data frame - in that case pieces will be combined with
+ \code{\link{rbind.fill}}. If \code{.fun} returns an atomic vector of
+ fixed length, it will be \code{rbind}ed together and converted to a data
frame. Any other values will result in an error.
- If there are no results, then this function will return a
- data frame with zero rows and columns
- (\code{data.frame()}).
+ If there are no results, then this function will return a data
+ frame with zero rows and columns (\code{data.frame()}).
}
\references{
Hadley Wickham (2011). The Split-Apply-Combine Strategy
diff --git a/man/alply.Rd b/man/alply.Rd
index c4467be..dfe047e 100644
--- a/man/alply.Rd
+++ b/man/alply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/alply.r
\name{alply}
\alias{alply}
\title{Split array, apply function, and return results in a list.}
@@ -8,42 +9,38 @@ alply(.data, .margins, .fun = NULL, ..., .expand = TRUE,
.paropts = NULL, .dims = FALSE)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{matrix, array or data frame to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.margins}{a vector giving the subscripts to split up \code{data} by.
+1 splits up by rows, 2 by columns and c(1,2) by rows and columns, and so
+on for higher dimensions}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.fun}{function to apply to each piece}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.expand}{if \code{.data} is a data frame, should output be 1d (expand
+ = FALSE), with an element for each row; or nd (expand = TRUE), with a
+dimension for each variable.}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.data}{matrix, array or data frame to be processed}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.margins}{a vector giving the subscripts to split
- up \code{data} by. 1 splits up by rows, 2 by columns and
- c(1,2) by rows and columns, and so on for higher
- dimensions}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.expand}{if \code{.data} is a data frame, should
- output be 1d (expand = FALSE), with an element for each
- row; or nd (expand = TRUE), with a dimension for each
- variable.}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
- \item{.dims}{if \code{TRUE}, copy over dimensions and
- names from input.}
+\item{.dims}{if \code{TRUE}, copy over dimensions and names from input.}
}
\value{
list of results
@@ -62,13 +59,13 @@ margins given. For instance \code{alply(x, c(3,2), ...)} where
where the results are not atomic.
}
\section{Input}{
- This function splits matrices, arrays and data frames by
+ This function splits matrices, arrays and data frames by
dimensions
}
\section{Output}{
- If there are no results, then this function will return a
- list of length 0 (\code{list()}).
+ If there are no results, then this function will return
+ a list of length 0 (\code{list()}).
}
\examples{
alply(ozone, 3, quantile)
diff --git a/man/amv_dim.Rd b/man/amv_dim.Rd
index e123ff9..f208013 100644
--- a/man/amv_dim.Rd
+++ b/man/amv_dim.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/dimensions.r
\name{amv_dim}
\alias{amv_dim}
\title{Dimensions.}
@@ -6,7 +7,7 @@
amv_dim(x)
}
\arguments{
- \item{x}{array, matrix or vector}
+\item{x}{array, matrix or vector}
}
\description{
Consistent dimensions for vectors, matrices and arrays.
diff --git a/man/amv_dimnames.Rd b/man/amv_dimnames.Rd
index e797881..8732ebe 100644
--- a/man/amv_dimnames.Rd
+++ b/man/amv_dimnames.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/dimensions.r
\name{amv_dimnames}
\alias{amv_dimnames}
\title{Dimension names.}
@@ -6,7 +7,7 @@
amv_dimnames(x)
}
\arguments{
- \item{x}{array, matrix or vector}
+\item{x}{array, matrix or vector}
}
\description{
Consistent dimnames for vectors, matrices and arrays.
diff --git a/man/arrange.Rd b/man/arrange.Rd
index 1e62f54..7af1331 100644
--- a/man/arrange.Rd
+++ b/man/arrange.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/arrange.r
\name{arrange}
\alias{arrange}
\title{Order a data frame by its colums.}
@@ -6,10 +7,10 @@
arrange(df, ...)
}
\arguments{
- \item{df}{data frame to reorder}
+\item{df}{data frame to reorder}
- \item{...}{expressions evaluated in the context of
- \code{df} and then fed to \code{\link{order}}}
+\item{...}{expressions evaluated in the context of \code{df} and then fed
+to \code{\link{order}}}
}
\description{
This function completes the subsetting, transforming and ordering triad
diff --git a/man/as.data.frame.function.Rd b/man/as.data.frame.function.Rd
index 5b8bce0..7b98552 100644
--- a/man/as.data.frame.function.Rd
+++ b/man/as.data.frame.function.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/data-frame.r
\name{as.data.frame.function}
\alias{as.data.frame.function}
\title{Make a function return a data frame.}
@@ -6,23 +7,22 @@
\method{as.data.frame}{function}(x, row.names, optional, ...)
}
\arguments{
- \item{x}{function to make return a data frame}
+\item{x}{function to make return a data frame}
- \item{row.names}{necessary to match the generic, but not
- used}
+\item{row.names}{necessary to match the generic, but not used}
- \item{optional}{necessary to match the generic, but not
- used}
+\item{optional}{necessary to match the generic, but not used}
- \item{...}{necessary to match the generic, but not used}
+\item{...}{necessary to match the generic, but not used}
}
\description{
Create a new function that returns the existing function wrapped in a
-data.frame
+data.frame with a single column, \code{value}.
}
\details{
This is useful when calling \code{*dply} functions with a function that
-returns a vector, and you want the output in rows, rather than columns
+returns a vector, and you want the output in rows, rather than columns.
+The \code{value} column is always created, even for empty inputs.
}
\keyword{manip}
diff --git a/man/as.list.split.Rd b/man/as.list.split.Rd
index d7dd12b..f09f337 100644
--- a/man/as.list.split.Rd
+++ b/man/as.list.split.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/split.r
\name{as.list.split}
\alias{as.list.split}
\title{Convert split list to regular list.}
@@ -6,9 +7,9 @@
\method{as.list}{split}(x, ...)
}
\arguments{
- \item{x}{object to convert to a list}
+\item{x}{object to convert to a list}
- \item{...}{unused}
+\item{...}{unused}
}
\description{
Strip off label related attributed to make a strip list as regular list
diff --git a/man/as.quoted.Rd b/man/as.quoted.Rd
index 8c93983..28f381c 100644
--- a/man/as.quoted.Rd
+++ b/man/as.quoted.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/quote.r
\name{as.quoted}
\alias{as.quoted}
\title{Convert input to quoted variables.}
@@ -6,11 +7,11 @@
as.quoted(x, env = parent.frame())
}
\arguments{
- \item{x}{input to quote}
+\item{x}{input to quote}
- \item{env}{environment in which unbound symbols in
- expression should be evaluated. Defaults to the
- environment in which \code{as.quoted} was executed.}
+\item{env}{environment in which unbound symbols in expression should be
+evaluated. Defaults to the environment in which \code{as.quoted} was
+executed.}
}
\value{
a list of quoted variables
diff --git a/man/baseball.Rd b/man/baseball.Rd
index a24d60a..92c18c4 100644
--- a/man/baseball.Rd
+++ b/man/baseball.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/data.r
\docType{data}
\name{baseball}
\alias{baseball}
@@ -14,20 +15,33 @@ of 21,699 records, covering 1,228 players from 1871 to 2007. Only players
with more 15 seasons of play are included.
}
\section{Variables}{
- Variables: \itemize{ \item id, unique player id \item
- year, year of data \item stint \item team, team played
- for \item lg, league \item g, number of games \item ab,
- number of times at bat \item r, number of runs \item h,
- hits, times reached base because of a batted, fair ball
- without error by the defense \item X2b, hits on which the
- batter reached second base safely \item X3b, hits on
- which the batter reached third base safely \item hr,
- number of home runs \item rbi, runs batted in \item sb,
- stolen bases \item cs, caught stealing \item bb, base on
- balls (walk) \item so, strike outs \item ibb, intentional
- base on balls \item hbp, hits by pitch \item sh,
- sacrifice hits \item sf, sacrifice flies \item gidp,
- ground into double play }
+
+Variables:
+\itemize{
+ \item id, unique player id
+ \item year, year of data
+ \item stint
+ \item team, team played for
+ \item lg, league
+ \item g, number of games
+ \item ab, number of times at bat
+ \item r, number of runs
+ \item h, hits, times reached base because of a batted, fair ball without
+ error by the defense
+ \item X2b, hits on which the batter reached second base safely
+ \item X3b, hits on which the batter reached third base safely
+ \item hr, number of home runs
+ \item rbi, runs batted in
+ \item sb, stolen bases
+ \item cs, caught stealing
+ \item bb, base on balls (walk)
+ \item so, strike outs
+ \item ibb, intentional base on balls
+ \item hbp, hits by pitch
+ \item sh, sacrifice hits
+ \item sf, sacrifice flies
+ \item gidp, ground into double play
+}
}
\examples{
baberuth <- subset(baseball, id == "ruthba01")
diff --git a/man/colwise.Rd b/man/colwise.Rd
index 84b0f4a..0f6da91 100644
--- a/man/colwise.Rd
+++ b/man/colwise.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/colwise.r
\name{colwise}
\alias{catcolwise}
\alias{colwise}
@@ -12,13 +13,12 @@ catcolwise(.fun, ...)
numcolwise(.fun, ...)
}
\arguments{
- \item{.fun}{function}
+\item{.fun}{function}
- \item{.cols}{either a function that tests columns for
- inclusion, or a quoted object giving which columns to
- process}
+\item{.cols}{either a function that tests columns for inclusion, or a
+quoted object giving which columns to process}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{...}{other arguments passed on to \code{.fun}}
}
\description{
Turn a function that operates on a vector into a function that operates
diff --git a/man/compact.Rd b/man/compact.Rd
index 14dfa87..ee4ff93 100644
--- a/man/compact.Rd
+++ b/man/compact.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/utils.r
\name{compact}
\alias{compact}
\title{Compact list.}
@@ -6,7 +7,7 @@
compact(l)
}
\arguments{
- \item{l}{list}
+\item{l}{list}
}
\description{
Remove all NULL entries from a list
diff --git a/man/count.Rd b/man/count.Rd
index 8877a52..c061c4d 100644
--- a/man/count.Rd
+++ b/man/count.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/count.r
\name{count}
\alias{count}
\title{Count the number of occurences.}
@@ -6,13 +7,13 @@
count(df, vars = NULL, wt_var = NULL)
}
\arguments{
- \item{df}{data frame to be processed}
+\item{df}{data frame to be processed}
- \item{vars}{variables to count unique values of}
+\item{vars}{variables to count unique values of}
- \item{wt_var}{optional variable to weight by - if this is
- non-NULL, count will sum up the value of this variable
- for each combination of id variables.}
+\item{wt_var}{optional variable to weight by - if this is non-NULL, count
+will sum up the value of this variable for each combination of id
+variables.}
}
\value{
a data frame with label and freq columns
diff --git a/man/create_progress_bar.Rd b/man/create_progress_bar.Rd
index 5ebef45..5483bf5 100644
--- a/man/create_progress_bar.Rd
+++ b/man/create_progress_bar.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/progress.r
\name{create_progress_bar}
\alias{create_progress_bar}
\title{Create progress bar.}
@@ -6,10 +7,9 @@
create_progress_bar(name = "none", ...)
}
\arguments{
- \item{name}{type of progress bar to create}
+\item{name}{type of progress bar to create}
- \item{...}{other arguments passed onto progress bar
- function}
+\item{...}{other arguments passed onto progress bar function}
}
\description{
Create progress bar object from text string.
diff --git a/man/d_ply.Rd b/man/d_ply.Rd
index 3e9f6f5..87eaf6f 100644
--- a/man/d_ply.Rd
+++ b/man/d_ply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/d_ply.r
\name{d_ply}
\alias{d_ply}
\title{Split data frame, apply function, and discard results.}
@@ -8,55 +9,54 @@ d_ply(.data, .variables, .fun = NULL, ..., .progress = "none",
.paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{data frame to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.variables}{variables to split data frame by, as \code{\link{as.quoted}}
+variables, a formula or character vector}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.fun}{function to apply to each piece}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.data}{data frame to be processed}
+\item{.drop}{should combinations of variables that do not appear in the
+input data be preserved (FALSE) or dropped (TRUE, default)}
- \item{.variables}{variables to split data frame by, as
- \code{\link{as.quoted}} variables, a formula or character
- vector}
+\item{.print}{automatically print each result? (default: \code{FALSE})}
- \item{.drop}{should combinations of variables that do not
- appear in the input data be preserved (FALSE) or dropped
- (TRUE, default)}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.print}{automatically print each result? (default:
- \code{FALSE})}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
Nothing
}
\description{
-For each subset of a data frame, apply function and discard results
+For each subset of a data frame, apply function and discard results.
+To apply a function for each row, use \code{\link{a_ply}} with
+\code{.margins} set to \code{1}.
}
\section{Input}{
- This function splits data frames by variables.
+ This function splits data frames by variables.
}
\section{Output}{
- All output is discarded. This is useful for functions
- that you are calling purely for their side effects like
- displaying plots or saving output.
+
+ All output is discarded. This is useful for functions that you are
+ calling purely for their side effects like displaying plots or
+ saving output.
}
\references{
Hadley Wickham (2011). The Split-Apply-Combine Strategy
diff --git a/man/daply.Rd b/man/daply.Rd
index 2420af7..8deb34c 100644
--- a/man/daply.Rd
+++ b/man/daply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/daply.r
\name{daply}
\alias{daply}
\title{Split data frame, apply function, and return results in an array.}
@@ -8,40 +9,37 @@ daply(.data, .variables, .fun = NULL, ..., .progress = "none",
.paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{data frame to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.variables}{variables to split data frame by, as quoted
+variables, a formula or character vector}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.fun}{function to apply to each piece}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.data}{data frame to be processed}
+\item{.drop_i}{should combinations of variables that do not appear in the
+input data be preserved (FALSE) or dropped (TRUE, default)}
- \item{.variables}{variables to split data frame by, as
- quoted variables, a formula or character vector}
+\item{.drop_o}{should extra dimensions of length 1 in the output be
+dropped, simplifying the output. Defaults to \code{TRUE}}
- \item{.drop_i}{should combinations of variables that do
- not appear in the input data be preserved (FALSE) or
- dropped (TRUE, default)}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.drop_o}{should extra dimensions of length 1 in the
- output be dropped, simplifying the output. Defaults to
- \code{TRUE}}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
if results are atomic with same type and dimensionality, a
@@ -52,14 +50,17 @@ if results are atomic with same type and dimensionality, a
For each subset of data frame, apply function then combine results into
an array. \code{daply} with a function that operates column-wise is
similar to \code{\link{aggregate}}.
+To apply a function for each row, use \code{\link{aaply}} with
+\code{.margins} set to \code{1}.
}
\section{Input}{
- This function splits data frames by variables.
+ This function splits data frames by variables.
}
\section{Output}{
- If there are no results, then this function will return a
- vector of length 0 (\code{vector()}).
+
+ If there are no results, then this function will return a vector of
+ length 0 (\code{vector()}).
}
\examples{
daply(baseball, .(year), nrow)
diff --git a/man/ddply.Rd b/man/ddply.Rd
index 0b6430e..30a703d 100644
--- a/man/ddply.Rd
+++ b/man/ddply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/ddply.r
\name{ddply}
\alias{ddply}
\title{Split data frame, apply function, and return results in a data frame.}
@@ -7,37 +8,34 @@ ddply(.data, .variables, .fun = NULL, ..., .progress = "none",
.inform = FALSE, .drop = TRUE, .parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{data frame to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.variables}{variables to split data frame by, as \code{\link{as.quoted}}
+variables, a formula or character vector}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.fun}{function to apply to each piece}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.data}{data frame to be processed}
+\item{.drop}{should combinations of variables that do not appear in the
+input data be preserved (FALSE) or dropped (TRUE, default)}
- \item{.variables}{variables to split data frame by, as
- \code{\link{as.quoted}} variables, a formula or character
- vector}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.drop}{should combinations of variables that do not
- appear in the input data be preserved (FALSE) or dropped
- (TRUE, default)}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
A data frame, as described in the output section.
@@ -45,26 +43,26 @@ A data frame, as described in the output section.
\description{
For each subset of a data frame, apply function then combine results into a
data frame.
+To apply a function for each row, use \code{\link{adply}} with
+\code{.margins} set to \code{1}.
}
\section{Input}{
- This function splits data frames by variables.
+ This function splits data frames by variables.
}
\section{Output}{
- The most unambiguous behaviour is achieved when
- \code{.fun} returns a data frame - in that case pieces
- will be combined with \code{\link{rbind.fill}}. If
- \code{.fun} returns an atomic vector of fixed length, it
- will be \code{rbind}ed together and converted to a data
+
+ The most unambiguous behaviour is achieved when \code{.fun} returns a
+ data frame - in that case pieces will be combined with
+ \code{\link{rbind.fill}}. If \code{.fun} returns an atomic vector of
+ fixed length, it will be \code{rbind}ed together and converted to a data
frame. Any other values will result in an error.
- If there are no results, then this function will return a
- data frame with zero rows and columns
- (\code{data.frame()}).
+ If there are no results, then this function will return a data
+ frame with zero rows and columns (\code{data.frame()}).
}
\examples{
# Summarize a dataset by two variables
-require(plyr)
dfx <- data.frame(
group = c(rep('A', 8), rep('B', 15), rep('C', 6)),
sex = sample(c("M", "F"), size = 29, replace = TRUE),
diff --git a/man/defaults.Rd b/man/defaults.Rd
index 382c6d4..f02fa29 100644
--- a/man/defaults.Rd
+++ b/man/defaults.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/defaults.r
\name{defaults}
\alias{defaults}
\title{Set defaults.}
@@ -6,9 +7,9 @@
defaults(x, y)
}
\arguments{
- \item{x}{list of values}
+\item{x}{list of values}
- \item{y}{defaults}
+\item{y}{defaults}
}
\description{
Convient method for combining a list of values with their defaults.
diff --git a/man/desc.Rd b/man/desc.Rd
index 67528c7..39774ad 100644
--- a/man/desc.Rd
+++ b/man/desc.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/arrange.r
\name{desc}
\alias{desc}
\title{Descending order.}
@@ -6,7 +7,7 @@
desc(x)
}
\arguments{
- \item{x}{vector to transform}
+\item{x}{vector to transform}
}
\description{
Transform a vector into a format that will be sorted in descending order.
diff --git a/man/dims.Rd b/man/dims.Rd
index 7ba6cf2..1ec5191 100644
--- a/man/dims.Rd
+++ b/man/dims.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/dimensions.r
\name{dims}
\alias{dims}
\title{Number of dimensions.}
@@ -6,7 +7,7 @@
dims(x)
}
\arguments{
- \item{x}{array}
+\item{x}{array}
}
\description{
Number of dimensions of an array or vector
diff --git a/man/dlply.Rd b/man/dlply.Rd
index 0798ac2..df9b6c9 100644
--- a/man/dlply.Rd
+++ b/man/dlply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/dlply.r
\name{dlply}
\alias{dlply}
\title{Split data frame, apply function, and return results in a list.}
@@ -7,37 +8,34 @@ dlply(.data, .variables, .fun = NULL, ..., .progress = "none",
.inform = FALSE, .drop = TRUE, .parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{data frame to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.variables}{variables to split data frame by, as \code{\link{as.quoted}}
+variables, a formula or character vector}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.fun}{function to apply to each piece}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.data}{data frame to be processed}
+\item{.drop}{should combinations of variables that do not appear in the
+input data be preserved (FALSE) or dropped (TRUE, default)}
- \item{.variables}{variables to split data frame by, as
- \code{\link{as.quoted}} variables, a formula or character
- vector}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.drop}{should combinations of variables that do not
- appear in the input data be preserved (FALSE) or dropped
- (TRUE, default)}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
list of results
@@ -46,14 +44,16 @@ list of results
For each subset of a data frame, apply function then combine results into a
list. \code{dlply} is similar to \code{\link{by}} except that the results
are returned in a different format.
+To apply a function for each row, use \code{\link{alply}} with
+\code{.margins} set to \code{1}.
}
\section{Input}{
- This function splits data frames by variables.
+ This function splits data frames by variables.
}
\section{Output}{
- If there are no results, then this function will return a
- list of length 0 (\code{list()}).
+ If there are no results, then this function will return
+ a list of length 0 (\code{list()}).
}
\examples{
linmod <- function(df) {
diff --git a/man/each.Rd b/man/each.Rd
index 3f23e4c..51ed81b 100644
--- a/man/each.Rd
+++ b/man/each.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/each.r
\name{each}
\alias{each}
\title{Aggregate multiple functions into a single function.}
@@ -6,8 +7,8 @@
each(...)
}
\arguments{
- \item{...}{functions to combine. each function should
- produce a single number as output}
+\item{...}{functions to combine. each function should produce a single
+number as output}
}
\description{
Combine multiple functions into a single function returning a named vector
diff --git a/man/empty.Rd b/man/empty.Rd
index 0bcb618..5050a8d 100644
--- a/man/empty.Rd
+++ b/man/empty.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/utils.r
\name{empty}
\alias{empty}
\title{Check if a data frame is empty.}
@@ -6,7 +7,7 @@
empty(df)
}
\arguments{
- \item{df}{data frame to check}
+\item{df}{data frame to check}
}
\description{
Empty if it's null or it has 0 rows or columns
diff --git a/man/eval.quoted.Rd b/man/eval.quoted.Rd
index 45b8dee..1a54380 100644
--- a/man/eval.quoted.Rd
+++ b/man/eval.quoted.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/quote.r
\name{eval.quoted}
\alias{eval.quoted}
\title{Evaluate a quoted list of variables.}
@@ -6,10 +7,9 @@
eval.quoted(exprs, envir = NULL, enclos = NULL, try = FALSE)
}
\arguments{
- \item{expr}{quoted object to evalution}
+\item{try}{if TRUE, return \code{NULL} if evaluation unsuccesful}
- \item{try}{if TRUE, return \code{NULL} if evaluation
- unsuccesful}
+\item{expr}{quoted object to evalution}
}
\value{
a list
diff --git a/man/failwith.Rd b/man/failwith.Rd
index 3a61f07..d231c0f 100644
--- a/man/failwith.Rd
+++ b/man/failwith.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/try.r
\name{failwith}
\alias{failwith}
\title{Fail with specified value.}
@@ -6,11 +7,11 @@
failwith(default = NULL, f, quiet = FALSE)
}
\arguments{
- \item{default}{default value}
+\item{default}{default value}
- \item{f}{function}
+\item{f}{function}
- \item{quiet}{all error messages be suppressed?}
+\item{quiet}{all error messages be suppressed?}
}
\value{
a function
diff --git a/man/get-split.Rd b/man/get-split.Rd
index 35f394b..87bf5a3 100644
--- a/man/get-split.Rd
+++ b/man/get-split.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/split.r
\name{[.split}
\alias{[.split}
\title{Subset splits.}
@@ -6,11 +7,11 @@
\method{[}{split}(x, i, ...)
}
\arguments{
- \item{x}{split object}
+\item{x}{split object}
- \item{i}{index}
+\item{i}{index}
- \item{...}{unused}
+\item{...}{unused}
}
\description{
Subset splits, ensuring that labels keep matching
diff --git a/man/here.Rd b/man/here.Rd
index a13d72a..259350c 100644
--- a/man/here.Rd
+++ b/man/here.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/here.r
\name{here}
\alias{here}
\title{Capture current evaluation context.}
@@ -6,7 +7,7 @@
here(f)
}
\arguments{
- \item{f}{a function that does non-standard evaluation}
+\item{f}{a function that does non-standard evaluation}
}
\description{
This function captures the current context, making it easier
diff --git a/man/id.Rd b/man/id.Rd
index c9e63bd..dec3384 100644
--- a/man/id.Rd
+++ b/man/id.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/id.r
\name{id}
\alias{id}
\alias{ninteraction}
@@ -7,9 +8,9 @@
id(.variables, drop = FALSE)
}
\arguments{
- \item{.variables}{list of variables}
+\item{.variables}{list of variables}
- \item{drop}{drop unusued factor levels?}
+\item{drop}{drop unusued factor levels?}
}
\value{
a numeric vector with attribute n, giving total number of
diff --git a/man/id_var.Rd b/man/id_var.Rd
index 575feea..6b8ae3c 100644
--- a/man/id_var.Rd
+++ b/man/id_var.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/id.r
\name{id_var}
\alias{id_var}
\title{Numeric id for a vector.}
diff --git a/man/idata.frame.Rd b/man/idata.frame.Rd
index b44b6f4..268b294 100644
--- a/man/idata.frame.Rd
+++ b/man/idata.frame.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/idataframe.r
\name{idata.frame}
\alias{idata.frame}
\title{Construct an immutable data frame.}
@@ -6,7 +7,7 @@
idata.frame(df)
}
\arguments{
- \item{df}{a data frame}
+\item{df}{a data frame}
}
\value{
an immutable data frame
diff --git a/man/indexed_array.Rd b/man/indexed_array.Rd
index 94524af..41add9e 100644
--- a/man/indexed_array.Rd
+++ b/man/indexed_array.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/indexed-array.r
\name{indexed_array}
\alias{[[.indexed_array}
\alias{indexed_array}
@@ -9,9 +10,9 @@
indexed_array(env, index)
}
\arguments{
- \item{env}{environment containing data frame}
+\item{env}{environment containing data frame}
- \item{index}{list of indices}
+\item{index}{list of indices}
}
\description{
Create a indexed array, a space efficient way of indexing into a large
diff --git a/man/indexed_df.Rd b/man/indexed_df.Rd
index 974d9ef..6faabd7 100644
--- a/man/indexed_df.Rd
+++ b/man/indexed_df.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/indexed-data-frame.r
\name{indexed_df}
\alias{indexed_df}
\title{An indexed data frame.}
@@ -6,12 +7,11 @@
indexed_df(data, index, vars)
}
\arguments{
- \item{env}{environment containing data frame}
+\item{index}{list of indices}
- \item{index}{list of indices}
+\item{vars}{a character vector giving the variables used for subsetting}
- \item{vars}{a character vector giving the variables used
- for subsetting}
+\item{env}{environment containing data frame}
}
\description{
Create a indexed list, a space efficient way of indexing into a large data frame
diff --git a/man/is.discrete.Rd b/man/is.discrete.Rd
index 8f76914..ffccd5d 100644
--- a/man/is.discrete.Rd
+++ b/man/is.discrete.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/utils.r
\name{is.discrete}
\alias{is.discrete}
\title{Determine if a vector is discrete.}
@@ -6,7 +7,7 @@
is.discrete(x)
}
\arguments{
- \item{x}{vector to test}
+\item{x}{vector to test}
}
\description{
A discrete vector is a factor or a character vector
diff --git a/man/is.formula.Rd b/man/is.formula.Rd
index 38c507e..3852bda 100644
--- a/man/is.formula.Rd
+++ b/man/is.formula.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/utils.r
\name{is.formula}
\alias{is.formula}
\title{Is a formula?
diff --git a/man/isplit2.Rd b/man/isplit2.Rd
index 8af982b..51fffad 100644
--- a/man/isplit2.Rd
+++ b/man/isplit2.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/liply.r
\name{isplit2}
\alias{isplit2}
\title{Split iterator that returns values, not indices.}
@@ -8,5 +9,11 @@ isplit2(x, f, drop = FALSE, ...)
\description{
Split iterator that returns values, not indices.
}
+\section{Warning}{
+Deprecated, do not use in new code.
+}
+\seealso{
+\code{\link{plyr-deprecated}}
+}
\keyword{internal}
diff --git a/man/join.Rd b/man/join.Rd
index c010919..2e2582c 100644
--- a/man/join.Rd
+++ b/man/join.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/join.r
\name{join}
\alias{join}
\title{Join two data frames together.}
@@ -6,21 +7,20 @@
join(x, y, by = NULL, type = "left", match = "all")
}
\arguments{
- \item{x}{data frame}
+\item{x}{data frame}
- \item{y}{data frame}
+\item{y}{data frame}
- \item{by}{character vector of variable names to join by.
- If omitted, will match on all common variables.}
+\item{by}{character vector of variable names to join by. If omitted, will
+match on all common variables.}
- \item{type}{type of join: left (default), right, inner or
- full. See details for more information.}
+\item{type}{type of join: left (default), right, inner or full. See
+details for more information.}
- \item{match}{how should duplicate ids be matched? Either
- match just the \code{"first"} matching row, or match
- \code{"all"} matching rows. Defaults to \code{"all"} for
- compatibility with merge, but \code{"first"} is
- significantly faster.}
+\item{match}{how should duplicate ids be matched? Either match just the
+\code{"first"} matching row, or match \code{"all"} matching rows. Defaults
+to \code{"all"} for compatibility with merge, but \code{"first"} is
+significantly faster.}
}
\description{
Join, like merge, is designed for the types of problems
diff --git a/man/join.keys.Rd b/man/join.keys.Rd
index 00680d8..7c881df 100644
--- a/man/join.keys.Rd
+++ b/man/join.keys.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/join.r
\name{join.keys}
\alias{join.keys}
\title{Join keys.
@@ -7,11 +8,11 @@ Given two data frames, create a unique key for each row.}
join.keys(x, y, by)
}
\arguments{
- \item{x}{data frame}
+\item{x}{data frame}
- \item{y}{data frame}
+\item{y}{data frame}
- \item{by}{character vector of variable names to join by}
+\item{by}{character vector of variable names to join by}
}
\description{
Join keys.
diff --git a/man/join_all.Rd b/man/join_all.Rd
index 5b4d0d0..ffe854c 100644
--- a/man/join_all.Rd
+++ b/man/join_all.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/join-all.r
\name{join_all}
\alias{join_all}
\title{Recursively join a list of data frames.}
@@ -6,19 +7,18 @@
join_all(dfs, by = NULL, type = "left", match = "all")
}
\arguments{
- \item{dfs}{A list of data frames.}
+\item{dfs}{A list of data frames.}
- \item{by}{character vector of variable names to join by.
- If omitted, will match on all common variables.}
+\item{by}{character vector of variable names to join by. If omitted, will
+match on all common variables.}
- \item{type}{type of join: left (default), right, inner or
- full. See details for more information.}
+\item{type}{type of join: left (default), right, inner or full. See
+details for more information.}
- \item{match}{how should duplicate ids be matched? Either
- match just the \code{"first"} matching row, or match
- \code{"all"} matching rows. Defaults to \code{"all"} for
- compatibility with merge, but \code{"first"} is
- significantly faster.}
+\item{match}{how should duplicate ids be matched? Either match just the
+\code{"first"} matching row, or match \code{"all"} matching rows. Defaults
+to \code{"all"} for compatibility with merge, but \code{"first"} is
+significantly faster.}
}
\description{
Recursively join a list of data frames.
diff --git a/man/l_ply.Rd b/man/l_ply.Rd
index f41da5b..d3fa766 100644
--- a/man/l_ply.Rd
+++ b/man/l_ply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/l_ply.r
\name{l_ply}
\alias{l_ply}
\title{Split list, apply function, and discard results.}
@@ -7,32 +8,30 @@ l_ply(.data, .fun = NULL, ..., .progress = "none", .inform = FALSE,
.print = FALSE, .parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{list to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.fun}{function to apply to each piece}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.print}{automatically print each result? (default: \code{FALSE})}
- \item{.data}{list to be processed}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.print}{automatically print each result? (default:
- \code{FALSE})}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
Nothing
@@ -41,13 +40,18 @@ Nothing
For each element of a list, apply function and discard results
}
\section{Input}{
- This function splits lists by elements.
+ This function splits lists by elements.
}
\section{Output}{
- All output is discarded. This is useful for functions
- that you are calling purely for their side effects like
- displaying plots or saving output.
+
+ All output is discarded. This is useful for functions that you are
+ calling purely for their side effects like displaying plots or
+ saving output.
+}
+\examples{
+l_ply(llply(mtcars, round), table, .print = TRUE)
+l_ply(baseball, function(x) print(summary(x)))
}
\references{
Hadley Wickham (2011). The Split-Apply-Combine Strategy
diff --git a/man/laply.Rd b/man/laply.Rd
index dfaaa76..211a75b 100644
--- a/man/laply.Rd
+++ b/man/laply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/laply.r
\name{laply}
\alias{laply}
\title{Split list, apply function, and return results in an array.}
@@ -7,33 +8,31 @@ laply(.data, .fun = NULL, ..., .progress = "none", .inform = FALSE,
.drop = TRUE, .parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{list to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.fun}{function to apply to each piece}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.drop}{should extra dimensions of length 1 in the output be
+dropped, simplifying the output. Defaults to \code{TRUE}}
- \item{.data}{list to be processed}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.drop}{should extra dimensions of length 1 in the
- output be dropped, simplifying the output. Defaults to
- \code{TRUE}}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
if results are atomic with same type and dimensionality, a
@@ -51,12 +50,13 @@ respect \code{sapply} - each element of the list corresponds to a row,
not a column.
}
\section{Input}{
- This function splits lists by elements.
+ This function splits lists by elements.
}
\section{Output}{
- If there are no results, then this function will return a
- vector of length 0 (\code{vector()}).
+
+ If there are no results, then this function will return a vector of
+ length 0 (\code{vector()}).
}
\examples{
laply(baseball, is.factor)
diff --git a/man/ldply.Rd b/man/ldply.Rd
index aca7856..d38ff2b 100644
--- a/man/ldply.Rd
+++ b/man/ldply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/ldply.r
\name{ldply}
\alias{ldply}
\title{Split list, apply function, and return results in a data frame.}
@@ -7,36 +8,33 @@ ldply(.data, .fun = NULL, ..., .progress = "none", .inform = FALSE,
.parallel = FALSE, .paropts = NULL, .id = NA)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{list to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.fun}{function to apply to each piece}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.data}{list to be processed}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
- \item{.id}{name of the index column (used if \code{.data}
- is a named list). Pass \code{NULL} to avoid creation of
- the index column. For compatibility, omit this argument
- or pass \code{NA} to avoid converting the index column to
- a factor; in this case, \code{".id"} is used as colum
- name.}
+\item{.id}{name of the index column (used if \code{.data} is a named list).
+Pass \code{NULL} to avoid creation of the index column. For compatibility,
+omit this argument or pass \code{NA} to avoid converting the index column
+to a factor; in this case, \code{".id"} is used as colum name.}
}
\value{
A data frame, as described in the output section.
@@ -46,20 +44,19 @@ For each element of a list, apply function then combine results into a data
frame.
}
\section{Input}{
- This function splits lists by elements.
+ This function splits lists by elements.
}
\section{Output}{
- The most unambiguous behaviour is achieved when
- \code{.fun} returns a data frame - in that case pieces
- will be combined with \code{\link{rbind.fill}}. If
- \code{.fun} returns an atomic vector of fixed length, it
- will be \code{rbind}ed together and converted to a data
+
+ The most unambiguous behaviour is achieved when \code{.fun} returns a
+ data frame - in that case pieces will be combined with
+ \code{\link{rbind.fill}}. If \code{.fun} returns an atomic vector of
+ fixed length, it will be \code{rbind}ed together and converted to a data
frame. Any other values will result in an error.
- If there are no results, then this function will return a
- data frame with zero rows and columns
- (\code{data.frame()}).
+ If there are no results, then this function will return a data
+ frame with zero rows and columns (\code{data.frame()}).
}
\references{
Hadley Wickham (2011). The Split-Apply-Combine Strategy
diff --git a/man/liply.Rd b/man/liply.Rd
index c35fc8a..b88c12f 100644
--- a/man/liply.Rd
+++ b/man/liply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/liply.r
\name{liply}
\alias{liply}
\title{Experimental iterator based version of llply.}
@@ -6,11 +7,11 @@
liply(.iterator, .fun = NULL, ...)
}
\arguments{
- \item{.iterator}{iterator object}
+\item{.iterator}{iterator object}
- \item{.fun}{function to apply to each piece}
+\item{.fun}{function to apply to each piece}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{...}{other arguments passed on to \code{.fun}}
}
\description{
Because iterators do not have known length, \code{liply} starts by
@@ -19,16 +20,11 @@ whenever it runs out of space. This gives O(n ln n) performance rather
than the O(n ^ 2) performance from the naive strategy of growing the list
each time.
}
-\examples{
-if(require("iterators")) {
- system.time(dlply(baseball, "id", summarise, mean_rbi = mean(rbi)))
- system.time({
- baseball_id <- isplit2(baseball, baseball$id)
- liply(baseball_id, summarise, mean_rbi = mean(rbi, na.rm = TRUE))
- })
- # Iterators get used up:
- liply(baseball_id, summarise, mean_rbi = mean(rbi, na.rm = TRUE))
+\section{Warning}{
+Deprecated, do not use in new code.
}
+\seealso{
+\code{\link{plyr-deprecated}}
}
\keyword{manip}
diff --git a/man/list_to_array.Rd b/man/list_to_array.Rd
index 42689ae..8d175c2 100644
--- a/man/list_to_array.Rd
+++ b/man/list_to_array.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/list-to-array.r
\name{list_to_array}
\alias{list_to_array}
\title{List to array.}
@@ -6,13 +7,11 @@
list_to_array(res, labels = NULL, .drop = FALSE)
}
\arguments{
- \item{res}{list of input data}
+\item{res}{list of input data}
- \item{labels}{a data frame of labels, one row for each
- element of res}
+\item{labels}{a data frame of labels, one row for each element of res}
- \item{.drop}{should extra dimensions be dropped (TRUE) or
- preserved (FALSE)}
+\item{.drop}{should extra dimensions be dropped (TRUE) or preserved (FALSE)}
}
\description{
Reduce/simplify a list of homogenous objects to an array
diff --git a/man/list_to_dataframe.Rd b/man/list_to_dataframe.Rd
index d35ed9d..66b4055 100644
--- a/man/list_to_dataframe.Rd
+++ b/man/list_to_dataframe.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/list-to-dataframe.r
\name{list_to_dataframe}
\alias{list_to_dataframe}
\title{List to data frame.}
@@ -7,13 +8,12 @@ list_to_dataframe(res, labels = NULL, id_name = NULL,
id_as_factor = FALSE)
}
\arguments{
- \item{res}{list of input data}
+\item{res}{list of input data}
- \item{labels}{a data frame of labels, one row for each
- element of res}
+\item{labels}{a data frame of labels, one row for each element of res}
- \item{idname}{the name of the index column, \code{NULL}
- for no index column}
+\item{idname}{the name of the index column, \code{NULL} for no index
+column}
}
\description{
Reduce/simplify a list of homogenous objects to a data frame. All
diff --git a/man/list_to_vector.Rd b/man/list_to_vector.Rd
index 9a2e3e3..ed21b67 100644
--- a/man/list_to_vector.Rd
+++ b/man/list_to_vector.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/list-to-vector.r
\name{list_to_vector}
\alias{list_to_vector}
\title{List to vector.}
@@ -6,7 +7,7 @@
list_to_vector(res)
}
\arguments{
- \item{res}{list of input data}
+\item{res}{list of input data}
}
\description{
Reduce/simplify a list of homogenous objects to a vector
diff --git a/man/llply.Rd b/man/llply.Rd
index 907d9fe..d1d0d6d 100644
--- a/man/llply.Rd
+++ b/man/llply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/llply.r
\name{llply}
\alias{llply}
\title{Split list, apply function, and return results in a list.}
@@ -7,29 +8,28 @@ llply(.data, .fun = NULL, ..., .progress = "none", .inform = FALSE,
.parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{list to be processed}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.fun}{function to apply to each piece}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.data}{list to be processed}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
list of results
@@ -42,12 +42,12 @@ For each element of a list, apply function, keeping results as a list.
preserve labels and can display a progress bar.
}
\section{Input}{
- This function splits lists by elements.
+ This function splits lists by elements.
}
\section{Output}{
- If there are no results, then this function will return a
- list of length 0 (\code{list()}).
+ If there are no results, then this function will return
+ a list of length 0 (\code{list()}).
}
\examples{
llply(llply(mtcars, round), table)
diff --git a/man/loop_apply.Rd b/man/loop_apply.Rd
index 1251467..f3ac11b 100644
--- a/man/loop_apply.Rd
+++ b/man/loop_apply.Rd
@@ -1,16 +1,17 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/loop_apply.R
\name{loop_apply}
\alias{loop_apply}
\title{Loop apply}
\usage{
-loop_apply(n, f)
+loop_apply(n, f, env = parent.frame())
}
\arguments{
- \item{n}{length of sequence}
+\item{n}{length of sequence}
- \item{f}{function to apply to each integer}
+\item{f}{function to apply to each integer}
- \item{env}{environment in which to evaluate function}
+\item{env}{environment in which to evaluate function}
}
\description{
An optimised version of lapply for the special case of operating on
diff --git a/man/m_ply.Rd b/man/m_ply.Rd
index c6f2df2..35434cd 100644
--- a/man/m_ply.Rd
+++ b/man/m_ply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/m_ply.r
\name{m_ply}
\alias{m_ply}
\title{Call function with arguments in array or data frame, discarding results.}
@@ -7,37 +8,33 @@ m_ply(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none",
.inform = FALSE, .print = FALSE, .parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{matrix or data frame to use as source of arguments}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.fun}{function to apply to each piece}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{.expand}{should output be 1d (expand = FALSE), with an element for
+each row; or nd (expand = TRUE), with a dimension for each variable.}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.data}{matrix or data frame to use as source of
- arguments}
+\item{.print}{automatically print each result? (default: \code{FALSE})}
- \item{.expand}{should output be 1d (expand = FALSE), with
- an element for each row; or nd (expand = TRUE), with a
- dimension for each variable.}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.print}{automatically print each result? (default:
- \code{FALSE})}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
Nothing
@@ -53,14 +50,15 @@ are just a convenient wrapper around \code{a*ply} with \code{margins = 1}
and \code{.fun} wrapped in \code{\link{splat}}.
}
\section{Input}{
- Call a multi-argument function with values taken from
+ Call a multi-argument function with values taken from
columns of an data frame or array
}
\section{Output}{
- All output is discarded. This is useful for functions
- that you are calling purely for their side effects like
- displaying plots or saving output.
+
+ All output is discarded. This is useful for functions that you are
+ calling purely for their side effects like displaying plots or
+ saving output.
}
\references{
Hadley Wickham (2011). The Split-Apply-Combine Strategy
diff --git a/man/maply.Rd b/man/maply.Rd
index d67b2b9..ef96ad8 100644
--- a/man/maply.Rd
+++ b/man/maply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/maply.r
\name{maply}
\alias{maply}
\title{Call function with arguments in array or data frame, returning an array.}
@@ -7,38 +8,34 @@ maply(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none",
.inform = FALSE, .drop = TRUE, .parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{matrix or data frame to use as source of arguments}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.fun}{function to apply to each piece}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{.expand}{should output be 1d (expand = FALSE), with an element for
+each row; or nd (expand = TRUE), with a dimension for each variable.}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.data}{matrix or data frame to use as source of
- arguments}
+\item{.drop}{should extra dimensions of length 1 in the output be
+dropped, simplifying the output. Defaults to \code{TRUE}}
- \item{.expand}{should output be 1d (expand = FALSE), with
- an element for each row; or nd (expand = TRUE), with a
- dimension for each variable.}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.drop}{should extra dimensions of length 1 in the
- output be dropped, simplifying the output. Defaults to
- \code{TRUE}}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
if results are atomic with same type and dimensionality, a
@@ -56,13 +53,14 @@ are just a convenient wrapper around \code{a*ply} with \code{margins = 1}
and \code{.fun} wrapped in \code{\link{splat}}.
}
\section{Input}{
- Call a multi-argument function with values taken from
+ Call a multi-argument function with values taken from
columns of an data frame or array
}
\section{Output}{
- If there are no results, then this function will return a
- vector of length 0 (\code{vector()}).
+
+ If there are no results, then this function will return a vector of
+ length 0 (\code{vector()}).
}
\examples{
maply(cbind(mean = 1:5, sd = 1:5), rnorm, n = 5)
diff --git a/man/mapvalues.Rd b/man/mapvalues.Rd
index f058b72..942a775 100644
--- a/man/mapvalues.Rd
+++ b/man/mapvalues.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/revalue.r
\name{mapvalues}
\alias{mapvalues}
\title{Replace specified values with new values, in a vector or factor.}
@@ -6,14 +7,14 @@
mapvalues(x, from, to, warn_missing = TRUE)
}
\arguments{
- \item{x}{the factor or vector to modify}
+\item{x}{the factor or vector to modify}
- \item{from}{a vector of the items to replace}
+\item{from}{a vector of the items to replace}
- \item{to}{a vector of replacement values}
+\item{to}{a vector of replacement values}
- \item{warn_missing}{print a message if any of the old
- values are not actually present in \code{x}}
+\item{warn_missing}{print a message if any of the old values are
+ not actually present in \code{x}}
}
\description{
Item in \code{x} that match items \code{from} will be replaced by
diff --git a/man/match_df.Rd b/man/match_df.Rd
index 8051ad3..e38a173 100644
--- a/man/match_df.Rd
+++ b/man/match_df.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/match-df.r
\name{match_df}
\alias{match_df}
\title{Extract matching rows of a data frame.}
@@ -6,12 +7,12 @@
match_df(x, y, on = NULL)
}
\arguments{
- \item{x}{data frame to subset.}
+\item{x}{data frame to subset.}
- \item{y}{data frame defining matching rows.}
+\item{y}{data frame defining matching rows.}
- \item{on}{variables to match on - by default will use all
- variables common to both data frames.}
+\item{on}{variables to match on - by default will use all variables common
+to both data frames.}
}
\value{
a data frame
diff --git a/man/mdply.Rd b/man/mdply.Rd
index 236837b..79c45a7 100644
--- a/man/mdply.Rd
+++ b/man/mdply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/mdply.r
\name{mdply}
\alias{mdply}
\title{Call function with arguments in array or data frame, returning a data frame.}
@@ -7,34 +8,31 @@ mdply(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none",
.inform = FALSE, .parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{matrix or data frame to use as source of arguments}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.fun}{function to apply to each piece}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{.expand}{should output be 1d (expand = FALSE), with an element for
+each row; or nd (expand = TRUE), with a dimension for each variable.}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.data}{matrix or data frame to use as source of
- arguments}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.expand}{should output be 1d (expand = FALSE), with
- an element for each row; or nd (expand = TRUE), with a
- dimension for each variable.}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
A data frame, as described in the output section.
@@ -50,21 +48,20 @@ are just a convenient wrapper around \code{a*ply} with \code{margins = 1}
and \code{.fun} wrapped in \code{\link{splat}}.
}
\section{Input}{
- Call a multi-argument function with values taken from
+ Call a multi-argument function with values taken from
columns of an data frame or array
}
\section{Output}{
- The most unambiguous behaviour is achieved when
- \code{.fun} returns a data frame - in that case pieces
- will be combined with \code{\link{rbind.fill}}. If
- \code{.fun} returns an atomic vector of fixed length, it
- will be \code{rbind}ed together and converted to a data
+
+ The most unambiguous behaviour is achieved when \code{.fun} returns a
+ data frame - in that case pieces will be combined with
+ \code{\link{rbind.fill}}. If \code{.fun} returns an atomic vector of
+ fixed length, it will be \code{rbind}ed together and converted to a data
frame. Any other values will result in an error.
- If there are no results, then this function will return a
- data frame with zero rows and columns
- (\code{data.frame()}).
+ If there are no results, then this function will return a data
+ frame with zero rows and columns (\code{data.frame()}).
}
\examples{
mdply(data.frame(mean = 1:5, sd = 1:5), rnorm, n = 2)
diff --git a/man/mlply.Rd b/man/mlply.Rd
index d037fdc..1467a4b 100644
--- a/man/mlply.Rd
+++ b/man/mlply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/mlply.r
\name{mlply}
\alias{mlply}
\title{Call function with arguments in array or data frame, returning a list.}
@@ -7,34 +8,31 @@ mlply(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none",
.inform = FALSE, .parallel = FALSE, .paropts = NULL)
}
\arguments{
- \item{.fun}{function to apply to each piece}
+\item{.data}{matrix or data frame to use as source of arguments}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{.fun}{function to apply to each piece}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+\item{.expand}{should output be 1d (expand = FALSE), with an element for
+each row; or nd (expand = TRUE), with a dimension for each variable.}
- \item{.paropts}{a list of additional options passed into
- the \code{\link[foreach]{foreach}} function when parallel
- computation is enabled. This is important if (for
- example) your code relies on external data or packages:
- use the \code{.export} and \code{.packages} arguments to
- supply them so that all cluster nodes have the correct
- environment set up for computing.}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.inform}{produce informative error messages? This
- is turned off by by default because it substantially
- slows processing speed, but is very useful for debugging}
+\item{.inform}{produce informative error messages? This is turned off
+by default because it substantially slows processing speed, but is very
+useful for debugging}
- \item{.data}{matrix or data frame to use as source of
- arguments}
+\item{.parallel}{if \code{TRUE}, apply function in parallel, using parallel
+backend provided by foreach}
- \item{.expand}{should output be 1d (expand = FALSE), with
- an element for each row; or nd (expand = TRUE), with a
- dimension for each variable.}
+\item{.paropts}{a list of additional options passed into
+the \code{\link[foreach]{foreach}} function when parallel computation
+is enabled. This is important if (for example) your code relies on
+external data or packages: use the \code{.export} and \code{.packages}
+arguments to supply them so that all cluster nodes have the correct
+environment set up for computing.}
}
\value{
list of results
@@ -50,13 +48,13 @@ are just a convenient wrapper around \code{a*ply} with \code{margins = 1}
and \code{.fun} wrapped in \code{\link{splat}}.
}
\section{Input}{
- Call a multi-argument function with values taken from
+ Call a multi-argument function with values taken from
columns of an data frame or array
}
\section{Output}{
- If there are no results, then this function will return a
- list of length 0 (\code{list()}).
+ If there are no results, then this function will return
+ a list of length 0 (\code{list()}).
}
\examples{
mlply(cbind(1:4, 4:1), rep)
diff --git a/man/mutate.Rd b/man/mutate.Rd
index 3a21084..a4d929d 100644
--- a/man/mutate.Rd
+++ b/man/mutate.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/mutate.r
\name{mutate}
\alias{mutate}
\title{Mutate a data frame by adding new or replacing existing columns.}
@@ -6,10 +7,9 @@
mutate(.data, ...)
}
\arguments{
- \item{.data}{the data frame to transform}
+\item{.data}{the data frame to transform}
- \item{...}{named parameters giving definitions of new
- columns.}
+\item{...}{named parameters giving definitions of new columns.}
}
\description{
This function is very similar to \code{\link{transform}} but it executes
diff --git a/man/name_rows.Rd b/man/name_rows.Rd
index e4775c7..99cf38c 100644
--- a/man/name_rows.Rd
+++ b/man/name_rows.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/name-rows.r
\name{name_rows}
\alias{name_rows}
\title{Toggle row names between explicit and implicit.}
@@ -6,8 +7,8 @@
name_rows(df)
}
\arguments{
- \item{df}{a data.frame, with either \code{rownames}, or a
- column called \code{.rownames}.}
+\item{df}{a data.frame, with either \code{rownames}, or a column called
+\code{.rownames}.}
}
\description{
Plyr functions ignore row names, so this function provides a way to preserve
@@ -24,4 +25,5 @@ arrange(df, a)
arrange(name_rows(df), a)
name_rows(arrange(name_rows(df), a))
}
+\keyword{manip}
diff --git a/man/names.quoted.Rd b/man/names.quoted.Rd
index a67345f..a9c5870 100644
--- a/man/names.quoted.Rd
+++ b/man/names.quoted.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/quote.r
\name{names.quoted}
\alias{names.quoted}
\title{Compute names of quoted variables.}
diff --git a/man/nunique.Rd b/man/nunique.Rd
index ecc02ab..447cb6d 100644
--- a/man/nunique.Rd
+++ b/man/nunique.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/utils.r
\name{nunique}
\alias{nunique}
\title{Number of unique values.}
@@ -6,7 +7,7 @@
nunique(x)
}
\arguments{
- \item{x}{vector}
+\item{x}{vector}
}
\description{
Calculate number of unique values of a variable as efficiently as possible.
diff --git a/man/ozone.Rd b/man/ozone.Rd
index 84397af..2961c74 100644
--- a/man/ozone.Rd
+++ b/man/ozone.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/data.r
\docType{data}
\name{ozone}
\alias{ozone}
diff --git a/man/plyr-deprecated.Rd b/man/plyr-deprecated.Rd
new file mode 100644
index 0000000..9ce9ca7
--- /dev/null
+++ b/man/plyr-deprecated.Rd
@@ -0,0 +1,16 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/plyr-deprecated.r
+\name{plyr-deprecated}
+\alias{plyr-deprecated}
+\title{Deprecated Functions in Package plyr}
+\description{
+These functions are provided for compatibility with older versions of
+\code{plyr} only, and may be defunct as soon as the next release.
+}
+\details{
+\itemize{
+ \item \code{\link{liply}}
+ \item \code{\link{isplit2}}
+}
+}
+
diff --git a/man/plyr.Rd b/man/plyr.Rd
index 33dce14..7e6e1ea 100644
--- a/man/plyr.Rd
+++ b/man/plyr.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/plyr.r
\docType{package}
\name{plyr}
\alias{plyr}
@@ -29,42 +30,43 @@ as output, and \code{\link{l_ply}} takes a list as input and returns nothing
as output.
}
\section{Row names}{
- By design, no plyr function will preserve row names - in
- general it is too hard to know what should be done with
- them for many of the operations supported by plyr. If you
- want to preserve row names, use \code{\link{name_rows}}
- to convert them into an explicit column in your data
- frame, perform the plyr operations, and then use
- \code{\link{name_rows}} again to convert the column back
- into row names.
+
+
+By design, no plyr function will preserve row names - in general it is too
+hard to know what should be done with them for many of the operations
+supported by plyr. If you want to preserve row names, use
+\code{\link{name_rows}} to convert them into an explicit column in your
+data frame, perform the plyr operations, and then use \code{\link{name_rows}}
+again to convert the column back into row names.
}
\section{Helpers}{
- Plyr also provides a set of helper functions for common
- data analysis problems:
- \itemize{ \item \code{\link{arrange}}: re-order the rows
- of a data frame by specifying the columns to order by
- \item \code{\link{mutate}}: add new columns or modifying
- existing columns, like \code{\link{transform}}, but new
- columns can refer to other columns that you just created.
- \item \code{\link{summarise}}: like \code{\link{mutate}}
- but create a new data frame, not preserving any columns
- in the old data frame.
- \item \code{\link{join}}: an adapation of
- \code{\link{merge}} which is more similar to SQL, and has
- a much faster implementation if you only want to find the
- first match. \item \code{\link{match_df}}: a version of
- \code{\link{join}} that instead of returning the two
- tables combined together, only returns the rows in the
- first table that match the second.
+Plyr also provides a set of helper functions for common data analysis
+problems:
+
+\itemize{
+ \item \code{\link{arrange}}: re-order the rows of a data frame by
+ specifying the columns to order by
+ \item \code{\link{mutate}}: add new columns or modifying existing columns,
+ like \code{\link{transform}}, but new columns can refer to other columns
+ that you just created.
+ \item \code{\link{summarise}}: like \code{\link{mutate}} but create a
+ new data frame, not preserving any columns in the old data frame.
- \item \code{\link{colwise}}: make any function work
- colwise on a dataframe \item \code{\link{rename}}: easily
- rename columns in a data frame \item
- \code{\link{round_any}}: round a number to any degree of
- precision \item \code{\link{count}}: quickly count unique
- combinations and return return as a data frame. }
+ \item \code{\link{join}}: an adapation of \code{\link{merge}} which is
+ more similar to SQL, and has a much faster implementation if you only
+ want to find the first match.
+ \item \code{\link{match_df}}: a version of \code{\link{join}} that instead
+ of returning the two tables combined together, only returns the rows
+ in the first table that match the second.
+
+ \item \code{\link{colwise}}: make any function work colwise on a dataframe
+ \item \code{\link{rename}}: easily rename columns in a data frame
+ \item \code{\link{round_any}}: round a number to any degree of precision
+ \item \code{\link{count}}: quickly count unique combinations and return
+ return as a data frame.
+}
}
diff --git a/man/print.quoted.Rd b/man/print.quoted.Rd
index 8760fa4..a1101b0 100644
--- a/man/print.quoted.Rd
+++ b/man/print.quoted.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/quote.r
\name{print.quoted}
\alias{print.quoted}
\title{Print quoted variables.}
diff --git a/man/print.split.Rd b/man/print.split.Rd
index 09915f5..cda3ba0 100644
--- a/man/print.split.Rd
+++ b/man/print.split.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/split.r
\name{print.split}
\alias{print.split}
\title{Print split.}
@@ -6,9 +7,9 @@
\method{print}{split}(x, ...)
}
\arguments{
- \item{x}{object to print}
+\item{x}{object to print}
- \item{...}{unused}
+\item{...}{unused}
}
\description{
Don't print labels, so it appears like a regular list
diff --git a/man/progress_none.Rd b/man/progress_none.Rd
index 473c2b4..a0b1289 100644
--- a/man/progress_none.Rd
+++ b/man/progress_none.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/progress.r
\name{progress_none}
\alias{progress_none}
\title{Null progress bar}
diff --git a/man/progress_text.Rd b/man/progress_text.Rd
index 9c64c38..6ad2ac9 100644
--- a/man/progress_text.Rd
+++ b/man/progress_text.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/progress.r
\name{progress_text}
\alias{progress_text}
\title{Text progress bar.}
@@ -6,11 +7,9 @@
progress_text(style = 3, ...)
}
\arguments{
- \item{style}{style of text bar, see Details section of
- \code{\link{txtProgressBar}}}
+\item{style}{style of text bar, see Details section of \code{\link{txtProgressBar}}}
- \item{...}{other arugments passed on to
- \code{\link{txtProgressBar}}}
+\item{...}{other arugments passed on to \code{\link{txtProgressBar}}}
}
\description{
A textual progress bar
diff --git a/man/progress_time.Rd b/man/progress_time.Rd
index 7c22c7e..15ce00a 100644
--- a/man/progress_time.Rd
+++ b/man/progress_time.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/progress-time.r
\name{progress_time}
\alias{progress_time}
\title{Text progress bar with time.}
diff --git a/man/progress_tk.Rd b/man/progress_tk.Rd
index c0d3e3b..ed1bd64 100644
--- a/man/progress_tk.Rd
+++ b/man/progress_tk.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/progress.r
\name{progress_tk}
\alias{progress_tk}
\title{Graphical progress bar, powered by Tk.}
@@ -6,12 +7,11 @@
progress_tk(title = "plyr progress", label = "Working...", ...)
}
\arguments{
- \item{title}{window title}
+\item{title}{window title}
- \item{label}{progress bar label (inside window)}
+\item{label}{progress bar label (inside window)}
- \item{...}{other arguments passed on to
- \code{\link[tcltk]{tkProgressBar}}}
+\item{...}{other arguments passed on to \code{\link[tcltk]{tkProgressBar}}}
}
\description{
A graphical progress bar displayed in a Tk window
diff --git a/man/progress_win.Rd b/man/progress_win.Rd
index 1b66bd1..0a96197 100644
--- a/man/progress_win.Rd
+++ b/man/progress_win.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/progress.r
\name{progress_win}
\alias{progress_win}
\title{Graphical progress bar, powered by Windows.}
@@ -6,10 +7,9 @@
progress_win(title = "plyr progress", ...)
}
\arguments{
- \item{title}{window title}
+\item{title}{window title}
- \item{...}{other arguments passed on to
- \code{winProgressBar}}
+\item{...}{other arguments passed on to \code{winProgressBar}}
}
\description{
A graphical progress bar displayed in a separate window
diff --git a/man/quickdf.Rd b/man/quickdf.Rd
index e8a81c7..05ae8c6 100644
--- a/man/quickdf.Rd
+++ b/man/quickdf.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/quickdf.r
\name{quickdf}
\alias{quickdf}
\title{Quick data frame.}
@@ -6,7 +7,7 @@
quickdf(list)
}
\arguments{
- \item{list}{list to convert to data frame}
+\item{list}{list to convert to data frame}
}
\description{
Experimental version of \code{\link{as.data.frame}} that converts a
diff --git a/man/quoted.Rd b/man/quoted.Rd
index f80a173..2d1f8e9 100644
--- a/man/quoted.Rd
+++ b/man/quoted.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/quote.r
\name{.}
\alias{.}
\alias{is.quoted}
@@ -9,13 +10,11 @@ evaluation.}
.(..., .env = parent.frame())
}
\arguments{
- \item{...}{unevaluated expressions to be recorded.
- Specify names if you want the set the names of the
- resultant variables}
+\item{...}{unevaluated expressions to be recorded. Specify names if you
+want the set the names of the resultant variables}
- \item{.env}{environment in which unbound symbols in
- \code{...} should be evaluated. Defaults to the
- environment in which \code{.} was executed.}
+\item{.env}{environment in which unbound symbols in \code{...} should be
+evaluated. Defaults to the environment in which \code{.} was executed.}
}
\value{
list of symbol and language primitives
diff --git a/man/r_ply.Rd b/man/r_ply.Rd
index a859643..7a0ab5d 100644
--- a/man/r_ply.Rd
+++ b/man/r_ply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/r_ply.r
\name{r_ply}
\alias{r_ply}
\title{Replicate expression and discard results.}
@@ -6,15 +7,13 @@
r_ply(.n, .expr, .progress = "none", .print = FALSE)
}
\arguments{
- \item{.n}{number of times to evaluate the expression}
+\item{.n}{number of times to evaluate the expression}
- \item{.expr}{expression to evaluate}
+\item{.expr}{expression to evaluate}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.progress}{name of the progress bar to use, see \code{\link{create_progress_bar}}}
- \item{.print}{automatically print each result? (default:
- \code{FALSE})}
+\item{.print}{automatically print each result? (default: \code{FALSE})}
}
\description{
Evalulate expression n times then discard results
diff --git a/man/raply.Rd b/man/raply.Rd
index 28df831..36587c5 100644
--- a/man/raply.Rd
+++ b/man/raply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/raply.r
\name{raply}
\alias{raply}
\title{Replicate expression and return results in a array.}
@@ -6,16 +7,13 @@
raply(.n, .expr, .progress = "none", .drop = TRUE)
}
\arguments{
- \item{.n}{number of times to evaluate the expression}
+\item{.n}{number of times to evaluate the expression}
- \item{.expr}{expression to evaluate}
+\item{.expr}{expression to evaluate}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.progress}{name of the progress bar to use, see \code{\link{create_progress_bar}}}
- \item{.drop}{should extra dimensions of length 1 be
- dropped, simplifying the output. Defaults to
- \code{TRUE}}
+\item{.drop}{should extra dimensions of length 1 be dropped, simplifying the output. Defaults to \code{TRUE}}
}
\value{
if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
diff --git a/man/rbind.fill.Rd b/man/rbind.fill.Rd
index 9d7a3b7..cd81b70 100644
--- a/man/rbind.fill.Rd
+++ b/man/rbind.fill.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/rbind-fill.r
\name{rbind.fill}
\alias{rbind.fill}
\title{Combine data.frames by row, filling in missing columns.}
@@ -6,11 +7,10 @@
rbind.fill(...)
}
\arguments{
- \item{...}{input data frames to row bind together. The
- first argument can be a list of data frames, in which
- case all other arguments are ignored. Any NULL inputs
- are silently dropped. If all inputs are NULL, the output
- is NULL.}
+\item{...}{input data frames to row bind together. The first argument can
+be a list of data frames, in which case all other arguments are ignored.
+Any NULL inputs are silently dropped. If all inputs are NULL, the output
+is NULL.}
}
\value{
a single data frame
diff --git a/man/rbind.fill.matrix.Rd b/man/rbind.fill.matrix.Rd
index 1cc19cd..397813b 100644
--- a/man/rbind.fill.matrix.Rd
+++ b/man/rbind.fill.matrix.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/rbind-fill-matrix.r
\name{rbind.fill.matrix}
\alias{rbind.fill.matrix}
\title{Bind matrices by row, and fill missing columns with NA.}
@@ -6,9 +7,8 @@
rbind.fill.matrix(...)
}
\arguments{
- \item{...}{the matrices to rbind. The first argument can
- be a list of matrices, in which case all other arguments
- are ignored.}
+\item{...}{the matrices to rbind. The first argument can be a list of
+matrices, in which case all other arguments are ignored.}
}
\value{
a matrix with column names
diff --git a/man/rdply.Rd b/man/rdply.Rd
index ce3da6b..ea80a60 100644
--- a/man/rdply.Rd
+++ b/man/rdply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/rdply.r
\name{rdply}
\alias{rdply}
\title{Replicate expression and return results in a data frame.}
@@ -6,24 +7,22 @@
rdply(.n, .expr, .progress = "none", .id = NA)
}
\arguments{
- \item{.n}{number of times to evaluate the expression}
+\item{.n}{number of times to evaluate the expression}
- \item{.expr}{expression to evaluate}
+\item{.expr}{expression to evaluate}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.progress}{name of the progress bar to use, see
+\code{\link{create_progress_bar}}}
- \item{.id}{name of the index column. Pass \code{NULL} to
- avoid creation of the index column. For compatibility,
- omit this argument or pass \code{NA} to avoid converting
- the index column to a factor; in this case, \code{".n"}
- is used as colum name..}
+\item{.id}{name of the index column. Pass \code{NULL} to avoid creation of
+the index column. For compatibility, omit this argument or pass \code{NA}
+to use \code{".n"} as column name.}
}
\value{
a data frame
}
\description{
-Evalulate expression n times then combine results into a data frame
+Evaluate expression n times then combine results into a data frame
}
\details{
This function runs an expression multiple times, and combines the result into
diff --git a/man/reduce_dim.Rd b/man/reduce_dim.Rd
index d9c3861..3f7be63 100644
--- a/man/reduce_dim.Rd
+++ b/man/reduce_dim.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/dimensions.r
\name{reduce_dim}
\alias{reduce_dim}
\title{Reduce dimensions.}
@@ -6,7 +7,7 @@
reduce_dim(x)
}
\arguments{
- \item{x}{array}
+\item{x}{array}
}
\description{
Remove extraneous dimensions
diff --git a/man/rename.Rd b/man/rename.Rd
index ba8229e..322d5cc 100644
--- a/man/rename.Rd
+++ b/man/rename.Rd
@@ -1,20 +1,24 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/rename.r
\name{rename}
\alias{rename}
\title{Modify names by name, not position.}
\usage{
-rename(x, replace, warn_missing = TRUE)
+rename(x, replace, warn_missing = TRUE, warn_duplicated = TRUE)
}
\arguments{
- \item{x}{named object to modify}
+\item{x}{named object to modify}
- \item{replace}{named character vector, with new names as
- values, and old names as names.}
+\item{replace}{named character vector, with new names as values, and
+old names as names.}
- \item{warn_missing}{print a message if any of the old
- names are not actually present in \code{x}. Note: x is
- not altered: To save the result, you need to copy the
- returned data into a variable.}
+\item{warn_missing}{print a message if any of the old names are
+not actually present in \code{x}.}
+
+\item{warn_duplicated}{print a message if any name appears more
+ than once in \code{x} after the operation.
+Note: x is not altered: To save the result, you need to copy the returned
+ data into a variable.}
}
\description{
Modify names by name, not position.
@@ -22,7 +26,7 @@ Modify names by name, not position.
\examples{
x <- c("a" = 1, "b" = 2, d = 3, 4)
# Rename column d to "c", updating the variable "x" with the result
-x <- rename(x, replace=c("d" = "c"))
+x <- rename(x, replace = c("d" = "c"))
x
# Rename column "disp" to "displacement"
rename(mtcars, c("disp" = "displacement"))
diff --git a/man/revalue.Rd b/man/revalue.Rd
index 6e77f56..97e2bdb 100644
--- a/man/revalue.Rd
+++ b/man/revalue.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/revalue.r
\name{revalue}
\alias{revalue}
\title{Replace specified values with new values, in a factor or character vector.}
@@ -6,13 +7,13 @@
revalue(x, replace = NULL, warn_missing = TRUE)
}
\arguments{
- \item{x}{factor or character vector to modify}
+\item{x}{factor or character vector to modify}
- \item{replace}{named character vector, with new values as
- values, and old values as names.}
+\item{replace}{named character vector, with new values as values, and
+old values as names.}
- \item{warn_missing}{print a message if any of the old
- values are not actually present in \code{x}}
+\item{warn_missing}{print a message if any of the old values are
+ not actually present in \code{x}}
}
\description{
If \code{x} is a factor, the named levels of the factor will be
diff --git a/man/rlply.Rd b/man/rlply.Rd
index cf53ec5..96f23d0 100644
--- a/man/rlply.Rd
+++ b/man/rlply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/rlply.r
\name{rlply}
\alias{rlply}
\title{Replicate expression and return results in a list.}
@@ -6,12 +7,11 @@
rlply(.n, .expr, .progress = "none")
}
\arguments{
- \item{.n}{number of times to evaluate the expression}
+\item{.n}{number of times to evaluate the expression}
- \item{.expr}{expression to evaluate}
+\item{.expr}{expression to evaluate}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
+\item{.progress}{name of the progress bar to use, see \code{\link{create_progress_bar}}}
}
\value{
list of results
diff --git a/man/round_any.Rd b/man/round_any.Rd
index a3e807e..7fff842 100644
--- a/man/round_any.Rd
+++ b/man/round_any.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/round-any.r
\name{round_any}
\alias{round_any}
\title{Round to multiple of any number.}
@@ -6,13 +7,12 @@
round_any(x, accuracy, f = round)
}
\arguments{
- \item{x}{numeric or date-time (POSIXct) vector to round}
+\item{x}{numeric or date-time (POSIXct) vector to round}
- \item{accuracy}{number to round to; for POSIXct objects,
- a number of seconds}
+\item{accuracy}{number to round to; for POSIXct objects, a number of seconds}
- \item{f}{rounding function: \code{\link{floor}},
- \code{\link{ceiling}} or \code{\link{round}}}
+\item{f}{rounding function: \code{\link{floor}}, \code{\link{ceiling}} or
+\code{\link{round}}}
}
\description{
Round to multiple of any number.
diff --git a/man/splat.Rd b/man/splat.Rd
index c9c9390..b3943be 100644
--- a/man/splat.Rd
+++ b/man/splat.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/splat.r
\name{splat}
\alias{splat}
\title{`Splat' arguments to a function.}
@@ -6,7 +7,7 @@
splat(flat)
}
\arguments{
- \item{flat}{function to splat}
+\item{flat}{function to splat}
}
\value{
a function
diff --git a/man/split_indices.Rd b/man/split_indices.Rd
index c300422..545132f 100644
--- a/man/split_indices.Rd
+++ b/man/split_indices.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/RcppExports.R
\name{split_indices}
\alias{split_indices}
\title{Split indices.}
@@ -6,17 +7,18 @@
split_indices(group, n = 0L)
}
\arguments{
- \item{index}{integer indices}
+\item{n}{largest integer (may not appear in index). This is hint: if
+the largest value of \code{group} is bigger than \code{n}, the output
+will silently expand.}
- \item{n}{largest integer (may not appear in index). This
- is hint: if the largest value of \code{group} is bigger
- than \code{n}, the output will silently expand.}
+\item{index}{integer indices}
}
\description{
An optimised version of split for the special case of splitting row
-indices into groups, as used by \code{\link{splitter_d}}
+indices into groups, as used by \code{\link{splitter_d}}.
}
\examples{
+split_indices(sample(10, 100, rep = TRUE))
split_indices(sample(10, 100, rep = TRUE), 10)
}
\keyword{internal}
diff --git a/man/split_labels.Rd b/man/split_labels.Rd
index af91665..6f8ed38 100644
--- a/man/split_labels.Rd
+++ b/man/split_labels.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/splitter-d.r
\name{split_labels}
\alias{split_labels}
\title{Generate labels for split data frame.}
@@ -6,10 +7,9 @@
split_labels(splits, drop, id = plyr::id(splits, drop = TRUE))
}
\arguments{
- \item{list}{of variables to split up by}
+\item{list}{of variables to split up by}
- \item{whether}{all possible combinations should be
- considered, or only those present in the data}
+\item{whether}{all possible combinations should be considered, or only those present in the data}
}
\description{
Create data frame giving labels for split data frame.
diff --git a/man/splitter_a.Rd b/man/splitter_a.Rd
index 9a0ea79..0e039b0 100644
--- a/man/splitter_a.Rd
+++ b/man/splitter_a.Rd
@@ -1,21 +1,26 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/splitter-a.r
\name{splitter_a}
\alias{splitter_a}
\title{Split an array by .margins.}
\usage{
-splitter_a(data, .margins = 1L, .expand = TRUE)
+splitter_a(data, .margins = 1L, .expand = TRUE, .id = NA)
}
\arguments{
- \item{data}{>1d data structure (matrix, data.frame or
- array)}
+\item{data}{>1d data structure (matrix, data.frame or array)}
- \item{.margins}{a vector giving the subscripts to split
- up \code{data} by.}
+\item{.margins}{a vector giving the subscripts to split up \code{data} by.}
- \item{.expand}{if splitting a dataframe by row, should
- output be 1d (expand = FALSE), with an element for each
- row; or nd (expand = TRUE), with a dimension for each
- variable.}
+\item{.expand}{if splitting a dataframe by row, should output be 1d
+(expand = FALSE), with an element for each row; or nd (expand = TRUE),
+with a dimension for each variable.}
+
+\item{.id}{names of the split label.
+Pass \code{NULL} to avoid creation of split labels.
+Omit or pass \code{NA} to use the default names
+\code{"X1"}, \code{"X2"}, \ldots.
+Otherwise, this argument must have the same length as
+\code{.margins}.}
}
\value{
a list of lower-d slices, with attributes that record split details
diff --git a/man/splitter_d.Rd b/man/splitter_d.Rd
index 3475dcc..5873044 100644
--- a/man/splitter_d.Rd
+++ b/man/splitter_d.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/splitter-d.r
\name{splitter_d}
\alias{splitter_d}
\title{Split a data frame by variables.}
@@ -6,11 +7,11 @@
splitter_d(data, .variables = NULL, drop = TRUE)
}
\arguments{
- \item{data}{data frame}
+\item{data}{data frame}
- \item{.variables}{a \link{quoted} list of variables}
+\item{.variables}{a \link{quoted} list of variables}
- \item{drop}{drop unnused factor levels?}
+\item{drop}{drop unnused factor levels?}
}
\value{
a list of data.frames, with attributes that record split details
diff --git a/man/strip_splits.Rd b/man/strip_splits.Rd
index 94f2110..ec68d18 100644
--- a/man/strip_splits.Rd
+++ b/man/strip_splits.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/strip-splits.r
\name{strip_splits}
\alias{strip_splits}
\title{Remove splitting variables from a data frame.}
@@ -6,7 +7,7 @@
strip_splits(df)
}
\arguments{
- \item{df}{data frame produced by \code{d*ply}.}
+\item{df}{data frame produced by \code{d*ply}.}
}
\description{
This is useful when you want to perform some operation to every column
diff --git a/man/summarise.Rd b/man/summarise.Rd
index 6a29899..fcad932 100644
--- a/man/summarise.Rd
+++ b/man/summarise.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/summarise.r
\name{summarise}
\alias{summarise}
\alias{summarize}
@@ -7,9 +8,9 @@
summarise(.data, ...)
}
\arguments{
- \item{.data}{the data frame to be summarised}
+\item{.data}{the data frame to be summarised}
- \item{...}{further arguments of the form var = value}
+\item{...}{further arguments of the form var = value}
}
\description{
Summarise works in an analogous way to \code{\link{mutate}}, except
diff --git a/man/take.Rd b/man/take.Rd
index b74a232..37286a7 100644
--- a/man/take.Rd
+++ b/man/take.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/take.r
\name{take}
\alias{take}
\title{Take a subset along an arbitrary dimension}
@@ -6,15 +7,14 @@
take(x, along, indices, drop = FALSE)
}
\arguments{
- \item{x}{matrix or array to subset}
+\item{x}{matrix or array to subset}
- \item{along}{dimension to subset along}
+\item{along}{dimension to subset along}
- \item{indices}{the indices to select}
+\item{indices}{the indices to select}
- \item{drop}{should the dimensions of the array be
- simplified? Defaults to \code{FALSE} which is the
- opposite of the useful R default.}
+\item{drop}{should the dimensions of the array be simplified? Defaults
+to \code{FALSE} which is the opposite of the useful R default.}
}
\description{
Take a subset along an arbitrary dimension
@@ -28,4 +28,5 @@ take(x, 3, 1, drop = TRUE)
take(x, 2, 1, drop = TRUE)
take(x, 1, 1, drop = TRUE)
}
+\keyword{manip}
diff --git a/man/true.Rd b/man/true.Rd
index d20fc58..52fc7b8 100644
--- a/man/true.Rd
+++ b/man/true.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/utils.r
\name{true}
\alias{true}
\title{Function that always returns true.}
@@ -6,7 +7,7 @@
true(...)
}
\arguments{
- \item{...}{all input ignored}
+\item{...}{all input ignored}
}
\value{
\code{TRUE}
diff --git a/man/try_default.Rd b/man/try_default.Rd
index a718186..af5ae64 100644
--- a/man/try_default.Rd
+++ b/man/try_default.Rd
@@ -1,23 +1,23 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/try.r
\name{try_default}
\alias{tryNULL}
\alias{try_default}
\title{Try, with default in case of error.}
\usage{
try_default(expr, default, quiet = FALSE)
+
+tryNULL(expr)
}
\arguments{
- \item{expr}{expression to try}
+\item{expr}{expression to try}
- \item{default}{default value in case of error}
+\item{default}{default value in case of error}
- \item{quiet}{should errors be printed (TRUE) or ignored
- (FALSE, default)}
+\item{quiet}{should errors be printed (TRUE) or ignored (FALSE, default)}
}
\description{
\code{try_default} wraps try so that it returns a default value in the case of error.
-}
-\details{
\code{tryNULL} provides a useful special case when dealing with lists.
}
\seealso{
diff --git a/man/tryapply.Rd b/man/tryapply.Rd
index 3276573..a9bfa98 100644
--- a/man/tryapply.Rd
+++ b/man/tryapply.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/try.r
\name{tryapply}
\alias{tryapply}
\title{Apply with built in try.
@@ -6,6 +7,13 @@ Uses compact, lapply and tryNULL}
\usage{
tryapply(list, fun, ...)
}
+\arguments{
+\item{list}{list to apply function \code{f} on}
+
+\item{...}{further arguments to \code{f}}
+
+\item{f}{function}
+}
\description{
Apply with built in try.
Uses compact, lapply and tryNULL
diff --git a/man/unrowname.Rd b/man/unrowname.Rd
index 0593054..7215172 100644
--- a/man/unrowname.Rd
+++ b/man/unrowname.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/utils.r
\name{unrowname}
\alias{unrowname}
\title{Un-rowname.}
@@ -6,7 +7,7 @@
unrowname(x)
}
\arguments{
- \item{x}{data frame}
+\item{x}{data frame}
}
\description{
Strip rownames from an object
diff --git a/man/vaggregate.Rd b/man/vaggregate.Rd
index bf74ab2..a534ac0 100644
--- a/man/vaggregate.Rd
+++ b/man/vaggregate.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/vaggregate.r
\name{vaggregate}
\alias{vaggregate}
\title{Vector aggregate.}
@@ -6,19 +7,18 @@
vaggregate(.value, .group, .fun, ..., .default = NULL, .n = nlevels(.group))
}
\arguments{
- \item{.value}{vector of values to aggregate}
+\item{.value}{vector of values to aggregate}
- \item{.group}{grouping vector}
+\item{.group}{grouping vector}
- \item{.fun}{aggregation function}
+\item{.fun}{aggregation function}
- \item{...}{other arguments passed on to \code{.fun}}
+\item{...}{other arguments passed on to \code{.fun}}
- \item{.default}{default value used for missing groups.
- This argument is also used as the template for function
- output.}
+\item{.default}{default value used for missing groups. This argument is
+also used as the template for function output.}
- \item{.n}{total number of groups}
+\item{.n}{total number of groups}
}
\description{
This function is somewhat similar to \code{tapply}, but is designed for
diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp
index eac1875..bf80ca8 100644
--- a/src/RcppExports.cpp
+++ b/src/RcppExports.cpp
@@ -5,35 +5,15 @@
using namespace Rcpp;
-// loop_apply
-List loop_apply(int n, Function f);
-RcppExport SEXP plyr_loop_apply(SEXP nSEXP, SEXP fSEXP) {
-BEGIN_RCPP
- SEXP __sexp_result;
- {
- Rcpp::RNGScope __rngScope;
- Rcpp::traits::input_parameter< int >::type n(nSEXP );
- Rcpp::traits::input_parameter< Function >::type f(fSEXP );
- List __result = loop_apply(n, f);
- PROTECT(__sexp_result = Rcpp::wrap(__result));
- }
- UNPROTECT(1);
- return __sexp_result;
-END_RCPP
-}
// split_indices
-std::vector<std::vector<int> > split_indices(IntegerVector group, int n = 0);
+std::vector<std::vector<int> > split_indices(IntegerVector group, int n);
RcppExport SEXP plyr_split_indices(SEXP groupSEXP, SEXP nSEXP) {
BEGIN_RCPP
- SEXP __sexp_result;
- {
- Rcpp::RNGScope __rngScope;
- Rcpp::traits::input_parameter< IntegerVector >::type group(groupSEXP );
- Rcpp::traits::input_parameter< int >::type n(nSEXP );
- std::vector<std::vector<int> > __result = split_indices(group, n);
- PROTECT(__sexp_result = Rcpp::wrap(__result));
- }
- UNPROTECT(1);
- return __sexp_result;
+ Rcpp::RObject __result;
+ Rcpp::RNGScope __rngScope;
+ Rcpp::traits::input_parameter< IntegerVector >::type group(groupSEXP);
+ Rcpp::traits::input_parameter< int >::type n(nSEXP);
+ __result = Rcpp::wrap(split_indices(group, n));
+ return __result;
END_RCPP
}
diff --git a/src/loop-apply.cpp b/src/loop-apply.cpp
deleted file mode 100644
index 577be20..0000000
--- a/src/loop-apply.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <Rcpp.h>
-using namespace Rcpp;
-
-//' Loop apply
-//'
-//' An optimised version of lapply for the special case of operating on
-//' \code{seq_len(n)}
-//'
-//' @param n length of sequence
-//' @param f function to apply to each integer
-//' @param env environment in which to evaluate function
-//' @useDynLib plyr
-//' @keywords internal manip
-// [[Rcpp::export]]
-List loop_apply(int n, Function f) {
- List out(n);
-
- for(int i = 0; i < n; ++i) {
- out[i] = f(i + 1);
- }
-
- return out;
-}
diff --git a/src/loop_apply.c b/src/loop_apply.c
new file mode 100644
index 0000000..9938a68
--- /dev/null
+++ b/src/loop_apply.c
@@ -0,0 +1,25 @@
+#include <R.h>
+#include <Rdefines.h>
+
+SEXP loop_apply(SEXP n, SEXP f, SEXP rho) {
+ if(!isFunction(f)) error("'f' must be a function");
+ if(!isEnvironment(rho)) error("'rho' should be an environment");
+
+ int n1 = INTEGER(n)[0];
+
+ SEXP results, R_fcall;
+ PROTECT(results = allocVector(VECSXP, n1));
+ PROTECT(R_fcall = lang2(f, R_NilValue));
+
+ SEXP ii;
+ for(int i = 0; i < n1; i++) {
+ PROTECT(ii = ScalarInteger(i + 1));
+ SETCADR(R_fcall, ii);
+ SET_VECTOR_ELT(results, i, eval(R_fcall, rho));
+
+ UNPROTECT(1);
+ }
+
+ UNPROTECT(2);
+ return results;
+}
diff --git a/src/split-numeric.cpp b/src/split-numeric.cpp
index 97a6ca4..0f6ac1b 100644
--- a/src/split-numeric.cpp
+++ b/src/split-numeric.cpp
@@ -4,31 +4,33 @@ using namespace Rcpp;
//' Split indices.
//'
//' An optimised version of split for the special case of splitting row
-//' indices into groups, as used by \code{\link{splitter_d}}
+//' indices into groups, as used by \code{\link{splitter_d}}.
//'
//' @param index integer indices
-//' @param n largest integer (may not appear in index). This is hint: if
+//' @param n largest integer (may not appear in index). This is hint: if
//' the largest value of \code{group} is bigger than \code{n}, the output
//' will silently expand.
//' @useDynLib plyr
//' @keywords internal manip
//' @export
//' @examples
+//' split_indices(sample(10, 100, rep = TRUE))
//' split_indices(sample(10, 100, rep = TRUE), 10)
// [[Rcpp::export]]
std::vector<std::vector<int> > split_indices(IntegerVector group, int n = 0) {
if (n < 0) stop("n must be a positive integer");
-
+
std::vector<std::vector<int> > ids(n);
-
+
int nx = group.size();
for (int i = 0; i < nx; ++i) {
- if (group[i] > n) {
+ // group is 1-indexed
+ if (group[i] > (int) ids.size()) {
ids.resize(group[i]);
}
-
+
ids[group[i] - 1].push_back(i + 1);
}
-
+
return ids;
}
diff --git a/tests/test-all.R b/tests/testthat.R
similarity index 61%
rename from tests/test-all.R
rename to tests/testthat.R
index 0ca0d68..88c5488 100644
--- a/tests/test-all.R
+++ b/tests/testthat.R
@@ -1,4 +1,4 @@
library(testthat)
library(plyr)
-test_package("plyr")
+test_check("plyr")
diff --git a/inst/tests/quickdf.r b/tests/testthat/quickdf.r
similarity index 100%
rename from inst/tests/quickdf.r
rename to tests/testthat/quickdf.r
diff --git a/tests/testthat/test-arrange.r b/tests/testthat/test-arrange.r
new file mode 100644
index 0000000..3b99a07
--- /dev/null
+++ b/tests/testthat/test-arrange.r
@@ -0,0 +1,9 @@
+context("Arrange")
+
+test_that("bogus sort order", {
+ expect_error(arrange(mtcars, diff(mpg)), "Length of ordering vectors")
+})
+
+test_that("descending sort", {
+ expect_equal(arrange(mtcars, desc(mpg)), arrange(mtcars, -mpg))
+})
diff --git a/inst/tests/test-array.r b/tests/testthat/test-array.r
similarity index 88%
rename from inst/tests/test-array.r
rename to tests/testthat/test-array.r
index 5ebf731..368779e 100644
--- a/inst/tests/test-array.r
+++ b/tests/testthat/test-array.r
@@ -74,14 +74,14 @@ test_that("idempotent function equivalent to permutation", {
dimnames = list(LETTERS[1:4], letters[24:26], letters[1:2]))
perms <- unique(alply(as.matrix(subset(expand.grid(x=0:3,y=0:3,z=0:3),
- (x+y+z)>0 & !any(duplicated(setdiff(c(x,y,z), 0))))),
+ (x + y + z) > 0 & !any(duplicated(setdiff(c(x,y,z), 0))))),
1,
function(x) setdiff(x, 0)))
aperms <- llply(perms, function(perm) aperm(x, unique(c(perm, 1:3))))
aaplys <- llply(perms, function(perm) aaply(x, perm, identity))
- for(i in seq_along(aperms)) {
+ for (i in seq_along(aperms)) {
perm <- paste(perms[[i]], collapse = ", ")
expect_that(dim(aaplys[[i]]), equals(dim(aperms[[i]])), perm)
expect_that(unname(dimnames(aaplys[[i]])), equals(dimnames(aperms[[i]])),
@@ -98,7 +98,7 @@ test_that("alply sets dims and dimnames, equivalence to permutation", {
#an aperm with the unused dimensions shifted to the front.
#check against all ways to split this array
p_alply <- unique(alply(as.matrix(subset(expand.grid(x=0:3,y=0:3,z=0:3),
- (x+y+z)>0 & !any(duplicated(setdiff(c(x,y,z), 0))))),
+ (x + y + z) > 0 & !any(duplicated(setdiff(c(x,y,z), 0))))),
1, function(x) setdiff(x, 0)))
p_aperm <- llply(p_alply, function(x) union(setdiff(1:3, x), x))
alplys <- lapply(p_alply, alply, .data=x, identity, .dims = TRUE)
@@ -170,7 +170,7 @@ test_that("array names do not affect output", {
alpha_rev = set_dimnames(base, list(R = letters[12:1], C = LETTERS[4:1]))
)
- for(name in names(arrays)) {
+ for (name in names(arrays)) {
array <- arrays[[name]]
expect_that(aaply(array, 1, sum),
equals(rowSums(array), check.attributes = FALSE), info = name)
@@ -179,3 +179,21 @@ test_that("array names do not affect output", {
}
})
+
+test_that("no support for duplicate names (#211)", {
+
+ n <- function(x) {
+ setNames(x, letters[c(1:9,2)])
+ }
+ B <- list(X=n(1:10), Y=n(11:20), Z=n(21:30))
+
+ expect_warning(laply(B, identity), "Duplicate names")
+
+ AB <- c('a', 'b', 'a', 'b')
+ ABCD <- c('a', 'b', 'c', 'd')
+ ar <- array(rep(rep(rep(1:4, 4), 4), 2), dim=c(4, 4, 2), dimnames=list(ABCD, ABCD, c('i', 'ii')))
+ ar[,,2] <- ar[,,2]+4
+ dimnames(ar)[1:2] <- list(AB, AB)
+ expect_warning(aaply(ar, 3, identity), "Duplicate names")
+
+})
diff --git a/inst/tests/test-count.r b/tests/testthat/test-count.r
similarity index 83%
rename from inst/tests/test-count.r
rename to tests/testthat/test-count.r
index 8c4c498..685d053 100644
--- a/inst/tests/test-count.r
+++ b/tests/testthat/test-count.r
@@ -13,7 +13,7 @@ test_that("count matches table", {
mtcars["mpg"],
mtcars[c("cyl", "vs")])
- for(datum in data) {
+ for (datum in data) {
expect_that(count_f(datum), equals(table_f(datum)))
}
@@ -22,7 +22,7 @@ test_that("count matches table", {
test_that("random order doesn't affect count", {
usual <- count(mtcars, "cyl")
- for(i in 1:5) {
+ for (i in 1:5) {
mtcars_r <- mtcars[sample(1:nrow(mtcars)), ]
expect_that(count(mtcars_r, "cyl"), equals(usual))
}
@@ -52,12 +52,18 @@ test_that("count works with factors and dates", {
genders <- c("Female", "Male")
n <- c(5, 10)
gender_data <- factor(rep.int(genders, n))
-
+
expect_equal(count(gender_data), data.frame(x = genders, freq = n))
-
+
this_week <- seq(Sys.Date(), Sys.Date() + 6, "1 day")
n2 <- 1:7
day_data <- rep(this_week, n2)
-
+
expect_equal(count(day_data), data.frame(x = this_week, freq = n2))
})
+
+test_that("vaggregate corner cases", {
+ res <- vaggregate(1:99, rep(1:11, 9), sum)
+ expect_equal(res, vaggregate(1:99, expand.grid(1:11, 1:9)[,1,drop=FALSE], sum))
+ expect_equal(res, vaggregate(1:99, rep(0.5 + (1:11), 9), sum, .default = 1))
+})
diff --git a/inst/tests/test-data-frame.r b/tests/testthat/test-data-frame.r
similarity index 71%
rename from inst/tests/test-data-frame.r
rename to tests/testthat/test-data-frame.r
index 88baaf0..89efa40 100644
--- a/inst/tests/test-data-frame.r
+++ b/tests/testthat/test-data-frame.r
@@ -62,14 +62,37 @@ test_that("label variables always preserved", {
})
# Test for #140
-test_that(".id column can be renamed", {
+test_that(".id column can be renamed or dropped", {
l <- llply(1:4, function(i) rep(i, i))
names(l) <- 1:4
f <- function(l) data.frame(sum=sum(unlist(l)))
-
+
out1 <- ldply(l, f)
out2 <- ldply(l, f, .id='x')
-
+ out3 <- ldply(l, f, .id=NULL)
+
expect_equal(names(out1), c('.id', 'sum'))
expect_equal(names(out2), c('x', 'sum'))
+ expect_equal(names(out3), c('sum'))
+
+ expect_identical(out1$.id, names(l))
+ expect_identical(out2$x, factor(names(l)))
+
+ out4 <- ldply(l, f, .id='sum') # names conflict
+ expect_equal(names(out4), c('sum'))
+
+ out5 <- ldply(l, f, .id=NA) # defaults
+ expect_equal(names(out5), c('.id', 'sum'))
+ expect_identical(out5$.id, names(l))
+
+ out6 <- ldply(l, f, .id='.id') # defaults
+ expect_equal(names(out6), c('.id', 'sum'))
+ expect_identical(out6$.id, factor(names(l)))
+
+ # no names = no .id column
+ expect_equal(ldply(unname(l), f, .id=NA), out3)
+ expect_equal(ldply(unname(l), f, .id="Name"), out3)
+ expect_equal(ldply(unname(l), f, .id=NULL), out3)
+
+ # todo: test for list with attr(,'split-labels'), needed?
})
diff --git a/tests/testthat/test-debug.r b/tests/testthat/test-debug.r
new file mode 100644
index 0000000..f3f636a
--- /dev/null
+++ b/tests/testthat/test-debug.r
@@ -0,0 +1,26 @@
+context("Debugging")
+
+test_that("failwith() function", {
+
+ expect_equal(failwith(1:10, stop, quiet = TRUE)("error"), 1:10)
+
+})
+
+test_that("tryNULL() function", {
+
+ old_options <- options(show.error.messages = FALSE)
+ on.exit(options(old_options), add = TRUE)
+ expect_equal(tryNULL(stop("error")), NULL)
+
+})
+
+test_that("tryapply() function", {
+
+ safe_divide <- function(y, x) {
+ stopifnot(y != 0)
+ x / y
+ }
+
+ expect_equal(tryapply(-3:3, safe_divide, x = 1), as.list(1 / (-3:3)[-4]))
+
+})
diff --git a/inst/tests/test-empty.r b/tests/testthat/test-empty.r
similarity index 100%
rename from inst/tests/test-empty.r
rename to tests/testthat/test-empty.r
diff --git a/tests/testthat/test-id.r b/tests/testthat/test-id.r
new file mode 100644
index 0000000..2bc9fae
--- /dev/null
+++ b/tests/testthat/test-id.r
@@ -0,0 +1,76 @@
+context("ID column name")
+
+test_that(".id parameter for ldply", {
+
+ data <- setNames(nm = 1:10)
+
+ expect_equal(names(ldply(data, identity)), c(".id", "V1"))
+ expect_equal(names(ldply(data, identity, .id = NULL)), c("V1"))
+ expect_equal(names(ldply(data, identity, .id = NA)), c(".id", "V1"))
+ expect_equal(names(ldply(data, identity, .id = "ID")), c("ID", "V1"))
+
+})
+
+test_that("ID column is a factor if .id argument is set", {
+
+ data <- setNames(nm = 1:10)
+
+ expect_false(is.factor(ldply(data, identity)$.id))
+ expect_true(is.factor(ldply(data, identity, .id = "ID")$ID))
+
+})
+
+test_that(".id parameter for rdply", {
+
+ expect_equal(names(rdply(10, 0)), c(".n", "V1"))
+ expect_false(is.factor(rdply(10, 0)$.n))
+ expect_equal(names(rdply(10, 0, .id = NULL)), c("V1"))
+ expect_equal(names(rdply(10, 0, .id = NA)), c(".n", "V1"))
+ expect_equal(names(rdply(10, 0, .id = "ID")), c("ID", "V1"))
+ expect_false(is.factor(rdply(10, 0, .id = "ID")$ID))
+
+})
+
+test_that(".id parameter for adply", {
+ data <- array(1:27, dim = c(3, 3, 3))
+
+ expect_equal(names(adply(data, 1, identity)), c("X1", "1", "2", "3"))
+ expect_equal(names(adply(data, 2, identity)), c("X1", "1", "2", "3"))
+ expect_equal(names(adply(data, 3, identity)), c("X1", "1", "2", "3"))
+ expect_equal(names(adply(data, c(1, 2), identity)), c("X1", "X2", "V1", "V2", "V3"))
+ expect_equal(names(adply(data, c(1, 3), identity)), c("X1", "X2", "V1", "V2", "V3"))
+ expect_equal(names(adply(data, c(1, 2, 3), identity)), c("X1", "X2", "X3", "V1"))
+ expect_equal(names(adply(data, c(), identity)), paste0("V", data))
+
+ expect_equal(names(adply(data, 1, identity, .id = NA)), c("X1", "1", "2", "3"))
+ expect_equal(names(adply(data, 2, identity, .id = NA)), c("X1", "1", "2", "3"))
+ expect_equal(names(adply(data, 3, identity, .id = NA)), c("X1", "1", "2", "3"))
+ expect_equal(names(adply(data, c(1, 2), identity, .id = NA)), c("X1", "X2", "V1", "V2", "V3"))
+ expect_equal(names(adply(data, c(1, 3), identity, .id = NA)), c("X1", "X2", "V1", "V2", "V3"))
+ expect_equal(names(adply(data, c(1, 2, 3), identity, .id = NA)), c("X1", "X2", "X3", "V1"))
+ expect_equal(names(adply(data, c(), identity, .id = NA)), paste0("V", data))
+
+ expect_equal(names(adply(data, 1, identity, .id = NULL)), c("1", "2", "3"))
+ expect_equal(names(adply(data, 2, identity, .id = NULL)), c("1", "2", "3"))
+ expect_equal(names(adply(data, 3, identity, .id = NULL)), c("1", "2", "3"))
+ expect_equal(names(adply(data, c(1, 2), identity, .id = NULL)), c("V1", "V2", "V3"))
+ expect_equal(names(adply(data, c(1, 3), identity, .id = NULL)), c("V1", "V2", "V3"))
+ expect_equal(names(adply(data, c(1, 2, 3), identity, .id = NULL)), c("V1"))
+ expect_equal(names(adply(data, c(), identity, .id = NULL)), paste0("V", data))
+
+ expect_equal(names(adply(data, 1, identity, .id = LETTERS[1])), c("A", "1", "2", "3"))
+ expect_equal(names(adply(data, 2, identity, .id = LETTERS[1])), c("A", "1", "2", "3"))
+ expect_equal(names(adply(data, 3, identity, .id = LETTERS[1])), c("A", "1", "2", "3"))
+ expect_equal(names(adply(data, c(1, 2), identity, .id = LETTERS[1:2])), c("A", "B", "V1", "V2", "V3"))
+ expect_equal(names(adply(data, c(1, 3), identity, .id = LETTERS[1:2])), c("A", "B", "V1", "V2", "V3"))
+ expect_equal(names(adply(data, c(1, 2, 3), identity, .id = LETTERS[1:3])), c("A", "B", "C", "V1"))
+
+ error_rx <- "[.]id argument.*number of margins"
+ expect_error(adply(data, 1, identity, .id = LETTERS[1:2]), error_rx)
+ expect_error(adply(data, 2, identity, .id = LETTERS[1:2]), error_rx)
+ expect_error(adply(data, 3, identity, .id = LETTERS[1:2]), error_rx)
+ expect_error(adply(data, c(1, 2), identity, .id = LETTERS[1:3]), error_rx)
+ expect_error(adply(data, c(1, 3), identity, .id = LETTERS[1:3]), error_rx)
+ expect_error(adply(data, c(1, 2, 3), identity, .id = LETTERS[1:4]), error_rx)
+ expect_error(adply(data, c(), identity, .id = LETTERS[1]), error_rx)
+})
diff --git a/inst/tests/test-idf.r b/tests/testthat/test-idf.r
similarity index 100%
rename from inst/tests/test-idf.r
rename to tests/testthat/test-idf.r
diff --git a/tests/testthat/test-inform.r b/tests/testthat/test-inform.r
new file mode 100644
index 0000000..28846a7
--- /dev/null
+++ b/tests/testthat/test-inform.r
@@ -0,0 +1,53 @@
+context("Informative messages")
+
+test_that(".inform parameter works for all l?ply functions", {
+ funcnames <- ls(name = asNamespace("plyr"), pattern = "^l[^i]ply$")
+
+ old_options <- options(show.error.messages = FALSE)
+ on.exit(options(old_options), add = TRUE)
+
+ input <- 1:10
+ for (funcname in funcnames) {
+ func <- get(funcname, asNamespace("plyr"))
+ expect_error(func(input, function(...) stop("qq"), .inform = TRUE), "piece 1", info = funcname)
+ }
+})
+
+test_that(".inform parameter works for all d?ply functions", {
+ funcnames <- ls(name = asNamespace("plyr"), pattern = "^d[^i]ply$")
+
+ old_options <- options(show.error.messages = FALSE)
+ on.exit(options(old_options), add = TRUE)
+
+ input <- data.frame(a = 1:10)
+ for (funcname in funcnames) {
+ func <- get(funcname, asNamespace("plyr"))
+ expect_error(func(input, .(), function(...) stop("qq"), .inform = TRUE), "piece 1", info = funcname)
+ }
+})
+
+test_that(".inform parameter works for all a?ply functions", {
+ funcnames <- ls(name = asNamespace("plyr"), pattern = "^a[^i]ply$")
+
+ old_options <- options(show.error.messages = FALSE)
+ on.exit(options(old_options), add = TRUE)
+
+ input <- data.frame(a = 1:10)
+ for (funcname in funcnames) {
+ func <- get(funcname, asNamespace("plyr"))
+ expect_error(func(input, 1, function(...) stop("qq"), .inform = TRUE), "piece 1", info = funcname)
+ }
+})
+
+test_that(".inform parameter works for all m?ply functions", {
+ funcnames <- ls(name = asNamespace("plyr"), pattern = "^m[^i]ply$")
+
+ old_options <- options(show.error.messages = FALSE)
+ on.exit(options(old_options), add = TRUE)
+
+ input <- data.frame(a = 1:10)
+ for (funcname in funcnames) {
+ func <- get(funcname, asNamespace("plyr"))
+ expect_error(func(input, function(...) stop("qq"), .inform = TRUE), "piece 1", info = funcname)
+ }
+})
diff --git a/inst/tests/test-join.r b/tests/testthat/test-join.r
similarity index 89%
rename from inst/tests/test-join.r
rename to tests/testthat/test-join.r
index 26ff8d3..04a6b04 100644
--- a/inst/tests/test-join.r
+++ b/tests/testthat/test-join.r
@@ -183,3 +183,25 @@ test_that("strings match to factors", {
expect_equal(3, nrow(join(dfF, matchS, type = "inner", by="species")))
})
+
+test_that("join_all", {
+
+ df <- expand.grid(.id = 1, a = 1:2, b = 4:5, c = letters[1:2], d = letters[4:5],
+ KEEP.OUT.ATTRS = FALSE, stringsAsFactors = FALSE)
+ df$.id <- as.integer(rownames(df))
+ expect_equal(join_all(list(df)), df)
+ expect_equal(join_all(list(df[, c(1,2)], df[, c(1,3,4,5)])), df)
+ expect_equal(join_all(list(df[, c(1,2)], df[, c(1,3,4)], df[, c(1,4,5)])), df)
+
+})
+
+test_that("match_df", {
+
+ df <- expand.grid(.id = 1, a = 1:2, b = 4:5, c = letters[1:2], d = letters[4:5],
+ KEEP.OUT.ATTRS = FALSE, stringsAsFactors = FALSE)
+
+ expect_equal(match_df(df, df), df)
+ expect_equal(match_df(df, df), df)
+ expect_equal(nrow(match_df(df, data.frame(a=1, b=4))), 4)
+
+})
diff --git a/inst/tests/test-list.r b/tests/testthat/test-list.r
similarity index 63%
rename from inst/tests/test-list.r
rename to tests/testthat/test-list.r
index d24db56..a1283d3 100644
--- a/inst/tests/test-list.r
+++ b/tests/testthat/test-list.r
@@ -21,12 +21,27 @@ test_that("list names are preserved", {
})
# Test for #142
-test_that(".n column can be renamed", {
+test_that(".n column can be renamed or dropped", {
f <- function() data.frame(r=runif(1))
-
+
out1 <- rdply(4, f)
out2 <- rdply(4, f, .id='x')
-
+
expect_equal(names(out1), c('.n', 'r'))
expect_equal(names(out2), c('x', 'r'))
+
+ # more testing
+ expect_identical(out1$.n, seq_len(4))
+ expect_identical(out2$x, seq_len(4))
+
+ out <- rdply(4, f, .id=NULL)
+ expect_equal(names(out), c('r'))
+ expect_false(out$r[4] == 4)
+
+ out <- rdply(4, f, .id='r') # names conflict
+ expect_equal(names(out), c('r'))
+
+ out <- rdply(4, f, .id='.n') # defaults
+ expect_equal(names(out), c('.n', 'r'))
+ expect_identical(out$.n, seq_len(4))
})
diff --git a/tests/testthat/test-manip.r b/tests/testthat/test-manip.r
new file mode 100644
index 0000000..bfb59ba
--- /dev/null
+++ b/tests/testthat/test-manip.r
@@ -0,0 +1,107 @@
+context("Manipulation")
+
+test_that("each() function", {
+
+ expect_equal(each(min, max)(1:10), c(min=1, max=10))
+ expect_equal(each(c(min, max))(1:10), c(min=1, max=10))
+ expect_equal(each(top=max, bottom=min)(1:10), c(top=10, bottom=1))
+ expect_equal(each(top=max, min)(1:10), c(top=10, min=1))
+ expect_equal(each(top="max", "min")(1:10), c(top=10, min=1))
+ expect_equal(each(c("min", max))(1:10), c(min=1, max=10))
+
+ # Odd behavior, kept for compatibility:
+ expect_equal(each(pmin)(1:10, 10:1), c(1:5, 5:1))
+ expect_equal(each(max, pmin)(1:10, 10:1), c(max=10, pmin=c(1:5, 5:1)))
+ expect_error(each()(1:10))
+
+})
+
+test_that("here() function", {
+
+ df <- data.frame(a = rep(c("a","b"), each = 10), b = 1:20)
+ f1 <- function(label) {
+ ddply(df, "a", mutate, label = paste(label, b))
+ }
+ expect_error(f1("name:"))
+
+ f2 <- function(label) {
+ ddply(df, "a", here(mutate), label = paste(label, b))
+ }
+ expect_true(all(grepl("^name: ", f2("name:")$label)))
+
+ f3 <- function() {
+ label <- "name:"
+ ddply(df, "a", here(mutate), label = paste(label, b))
+ }
+ expect_true(all(grepl("^name: ", f3()$label)))
+
+})
+
+test_that("defaults() function", {
+
+ expect_equal(defaults(c(a=1, b=2), c(c=3)), c(a=1, b=2, c=3))
+ expect_equal(defaults(c(a=1, b=2), c(a=3, b=4)), c(a=1, b=2))
+ expect_equal(defaults(c(a=1, b=2), c(a=3, d=4)), c(a=1, b=2, d=4))
+ expect_equal(defaults(c(a=1, b=2), c()), c(a=1, b=2))
+ expect_equal(defaults(c(), c(a=3, d=4)), c(a=3, d=4))
+
+})
+
+test_that("as.data.frame.function() function", {
+
+ expect_equal(as.data.frame(identity)(1:10), data.frame(value = 1:10))
+ expect_equal(as.data.frame(rev)(1:10), data.frame(value = 10:1))
+
+ # Always create value column, even if empty
+ expect_equal(as.data.frame(identity)(numeric()), data.frame(value = numeric()))
+
+})
+
+test_that("name_rows() function", {
+
+ expect_equal(name_rows(baseball)$.rownames, rownames(baseball))
+ expect_equal(rownames(name_rows(name_rows(baseball))), rownames(baseball))
+
+})
+
+test_that("round_any() function", {
+
+ expect_equal(round_any(135, 10), 140)
+ expect_equal(round_any(135, 100), 100)
+ expect_equal(round_any(135, 25), 125)
+ expect_equal(round_any(135, 10, floor), 130)
+ expect_equal(round_any(135, 100, floor), 100)
+ expect_equal(round_any(135, 25, floor), 125)
+ expect_equal(round_any(135, 10, ceiling), 140)
+ expect_equal(round_any(135, 100, ceiling), 200)
+ expect_equal(round_any(135, 25, ceiling), 150)
+
+ expect_equal(round_any(as.POSIXct("2000-01-01 11:00:00", tz="UTC"), 86400),
+ as.POSIXct("2000-01-01", tz="UTC"))
+ expect_equal(round_any(as.POSIXct("2000-01-01 11:11:11", tz="UTC"), 3600),
+ as.POSIXct("2000-01-01 11:00", tz="UTC"))
+ expect_equal(round_any(as.POSIXct("2000-01-01 11:11:11", tz="UTC"), 10, ceiling),
+ as.POSIXct("2000-01-01 11:11:20", tz="UTC"))
+
+})
+
+test_that("take() function", {
+
+ x <- array(seq_len(3 * 4 * 5), c(3, 4, 5))
+ expect_equal(take(x, 3, 1), x[,,1, drop = FALSE])
+ expect_equal(take(x, 2, 1), x[,1,, drop = FALSE])
+ expect_equal(take(x, 1, 1), x[1,,, drop = FALSE])
+ expect_equal(take(x, 3, 1, drop = TRUE), x[,,1])
+ expect_equal(take(x, 2, 1, drop = TRUE), x[,1,])
+ expect_equal(take(x, 1, 1, drop = TRUE), x[1,,])
+
+ expect_equal(take(x, 1:3, 3:5), x[3,4,5, drop = FALSE])
+ expect_equal(take(x, 1:2, 2:3), x[2,3,, drop = FALSE])
+ expect_equal(take(x, 2:3, 1:2), x[,1,2, drop = FALSE])
+
+ # Odd behavior, tested for compatibility:
+ expect_equal(take(x, 1:3, 1), x[1,1,1, drop = FALSE])
+ expect_equal(take(x, 1:2, 1), x[1,1,, drop = FALSE])
+ expect_equal(take(x, 2:3, 1), x[,1,1, drop = FALSE])
+
+})
diff --git a/inst/tests/test-mapply.r b/tests/testthat/test-mapply.r
similarity index 100%
rename from inst/tests/test-mapply.r
rename to tests/testthat/test-mapply.r
diff --git a/inst/tests/test-mutate.r b/tests/testthat/test-mutate.r
similarity index 56%
rename from inst/tests/test-mutate.r
rename to tests/testthat/test-mutate.r
index 385b9ec..eb9d1a5 100644
--- a/inst/tests/test-mutate.r
+++ b/tests/testthat/test-mutate.r
@@ -5,8 +5,8 @@ test_that("mutate behaves the same as transform", {
t1 <- transform(airquality, Ozone = -Ozone)
expect_that(m1, equals(t1))
- m2 <- mutate(airquality, new = -Ozone, Temp = (Temp-32)/1.8)
- t2 <- transform(airquality, new = -Ozone, Temp = (Temp-32)/1.8)
+ m2 <- mutate(airquality, new = -Ozone, Temp = (Temp - 32) / 1.8)
+ t2 <- transform(airquality, new = -Ozone, Temp = (Temp - 32) / 1.8)
expect_that(m2, equals(t2))
})
@@ -16,3 +16,9 @@ test_that("columns can depend on previously created", {
expect_that(m1$dm2, equals(dm2))
})
+
+test_that("mutating a column twice does not work", {
+ # For compatibility, see #218
+ m1 <- mutate(airquality, dm = 0, dm = Month + Day / 31)
+ expect_equal(m1$dm, rep(0, length(m1$dm)))
+})
diff --git a/inst/tests/test-ninteraction.r b/tests/testthat/test-ninteraction.r
similarity index 92%
rename from inst/tests/test-ninteraction.r
rename to tests/testthat/test-ninteraction.r
index 1d924f0..a19ced3 100644
--- a/inst/tests/test-ninteraction.r
+++ b/tests/testthat/test-ninteraction.r
@@ -7,7 +7,7 @@ simple_vectors <- list(
)
test_that("for vector, equivalent to rank", {
- for(case in simple_vectors) {
+ for (case in simple_vectors) {
rank <- rank(case, ties = "min")
rank_df <- id(as.data.frame(case))
@@ -16,7 +16,7 @@ test_that("for vector, equivalent to rank", {
})
test_that("duplicates numbered sequentially", {
- for(case in simple_vectors) {
+ for (case in simple_vectors) {
rank <- rep(rank(case, ties = "min"), each = 2)
rank_df <- id(as.data.frame(rep(case, each = 2)))
@@ -26,14 +26,14 @@ test_that("duplicates numbered sequentially", {
test_that("n calculated correctly", {
n <- function(x) attr(id(x), "n")
- for(case in simple_vectors) {
+ for (case in simple_vectors) {
expect_that(n(as.data.frame(case)), equals(26))
}
})
test_that("for vector + constant, equivalent to rank", {
- for(case in simple_vectors) {
+ for (case in simple_vectors) {
rank <- rank(case, ties = "min")
after <- id(data.frame(case, x = 1))
diff --git a/tests/testthat/test-parallel.r b/tests/testthat/test-parallel.r
new file mode 100644
index 0000000..106c5b0
--- /dev/null
+++ b/tests/testthat/test-parallel.r
@@ -0,0 +1,44 @@
+context("Parallel")
+
+with_parallel <- function(code) {
+ skip_on_cran()
+ skip_if_not_installed("doParallel")
+
+ doParallel::registerDoParallel(cores = 2)
+ on.exit(doParallel::stopImplicitCluster())
+ code
+}
+
+test_that("l_ply respects .parallel", {
+ with_parallel(
+ expect_that(
+ l_ply(c(0.1, 0.1), Sys.sleep, .parallel = TRUE),
+ takes_less_than(0.18))
+ )
+})
+
+test_that("l_ply + .parallel complains about invalid arguments", {
+ with_parallel({
+ expect_message(
+ l_ply(1:10, force, .parallel = TRUE, .print = TRUE),
+ "Printing disabled")
+ expect_message(
+ l_ply(1:10, force, .parallel = TRUE, .progress = "text"),
+ "Progress disabled")
+ })
+})
+
+test_that("llply + .parallel complains about invalid arguments", {
+ with_parallel({
+ expect_message(
+ llply(1:10, force, .parallel = TRUE, .progress = "text"),
+ "Progress disabled")
+ })
+})
+
+test_that(".paropts passes options to foreach", {
+ combine <- function(a, b) NULL
+ with_parallel(x <- llply(1:10, identity, .parallel = TRUE,
+ .paropts = list(.combine = combine)))
+ expect_equal(x, NULL)
+})
diff --git a/inst/tests/test-progress.r b/tests/testthat/test-progress.r
similarity index 56%
rename from inst/tests/test-progress.r
rename to tests/testthat/test-progress.r
index b848dab..d0f36eb 100644
--- a/inst/tests/test-progress.r
+++ b/tests/testthat/test-progress.r
@@ -1,10 +1,8 @@
context("Progress bars")
test_that("unknown progress bar raised warning, not error", {
- old <- options(warn = 2)
- on.exit(options(old))
- expect_that(
+ expect_warning(
llply(1:10, identity, .progress = "blah"),
- throws_error("Cannot find progress bar")
+ "Cannot find progress bar"
)
})
diff --git a/tests/testthat/test-quote.r b/tests/testthat/test-quote.r
new file mode 100644
index 0000000..34cc86d
--- /dev/null
+++ b/tests/testthat/test-quote.r
@@ -0,0 +1,70 @@
+context("Quoting")
+
+test_that("quoting captures current environment", {
+ x <- .(a, b, c)
+ expect_that(attr(x, "env"), is_identical_to(environment()))
+
+ x <- as.quoted(c("a", "b", "c"))
+ expect_that(attr(x, "env"), is_identical_to(environment()))
+})
+
+test_that("can't pass bogus environment for evaluation", {
+ expect_that(eval.quoted(.(x), envir = -1), throws_error("must be"))
+})
+
+test_that("evaluation takes place in correct environment", {
+ a <- 2
+ x <- local({
+ a <- 1
+ .(a)
+ })
+
+ expect_that(eval.quoted(x)$a, equals(1))
+
+ df <- data.frame(x = 1:10)
+ x <- local({
+ a <- 1
+ .(x * a)
+ })
+ expect_that(eval.quoted(x, df)[[1]], equals(1:10))
+
+})
+
+test_that("failsafe evaluation", {
+ b <- 2
+ x <- local({
+ a <- 1
+ .(a)
+ })
+
+ expect_that(eval.quoted(x, try = TRUE)$b, equals(NULL))
+})
+
+test_that("names work for long expressions", {
+ # nolint start
+ q <- .(foo = barjasdfgjadhfgjsdhfgusdhfgusheguisdhguioahsrofasdgsdfgsdfg +
+ dfgafgasdfgsdfgsdfgsdfgsdfgsdfgsdfg)
+ # nolint end
+ expect_that(names(q), equals("foo"))
+})
+
+test_that("printing works", {
+ expect_that(print(as.quoted(NULL)), testthat::prints_text("list()"))
+ expect_that(print(as.quoted("id")), testthat::prints_text("id"))
+ expect_that(print(as.quoted("3")), testthat::prints_text("3"))
+ expect_that(print(as.quoted(c("a", "b"))), testthat::prints_text("List of 2"))
+ expect_that(print(as.quoted(~a+b)), testthat::prints_text("List of 2"))
+ expect_that(print(as.quoted(~a)), testthat::prints_text("List of 1"))
+ expect_that(print(as.quoted(as.name("a"))), testthat::prints_text("List of 1"))
+})
+
+test_that("concatenation", {
+ expect_equal(c(.(a), .(b)), .(a, b))
+ expect_equal(c(.(a), .(b, c)), .(a, b, c))
+ expect_equal(c(.(a), .(b), .(c)), .(a, b, c))
+})
+
+test_that("extraction", {
+ expect_equal(.(a, b)[1], .(a))
+ expect_equal(.(a, b, c)[-1], .(b, c))
+})
diff --git a/inst/tests/test-rbind.matrix.r b/tests/testthat/test-rbind.matrix.r
similarity index 99%
rename from inst/tests/test-rbind.matrix.r
rename to tests/testthat/test-rbind.matrix.r
index d8ad036..ab7d326 100755
--- a/inst/tests/test-rbind.matrix.r
+++ b/tests/testthat/test-rbind.matrix.r
@@ -116,24 +116,22 @@ test_that("zero-row matrices", {
m1 <- matrix(nrow=0, ncol=2, dimnames=list(NULL, c("x", "y")))
m2 <- matrix(nrow=0, ncol=2, dimnames=list(NULL, c("y", "z")))
m3 <- matrix(c(1,2), nrow=2, ncol=1, dimnames=list(NULL, "y"))
-
+
ba <- rbind.fill.matrix(m1)
bb <- rbind.fill.matrix(m2, m3)
bc <- rbind.fill.matrix(m1, m2)
-
+
expect_equal(class(ba), "matrix")
expect_equal(nrow(ba), 0)
expect_true(all(colnames(ba) %in% c("x", "y")))
-
+
expect_equal(class(bb), "matrix")
expect_equal(nrow(bb), 2)
expect_true(all(names(bb) %in% c("x", "y", "z")))
expect_equal(bb[,"y"], m3[,"y"])
expect_equal(bb[,"z"], rep(as.numeric(NA), nrow(m3)))
-
+
expect_equal(class(bc), "matrix")
expect_equal(nrow(bc), 0)
expect_true(all(colnames(bc) %in% c("x", "y", "z")))
})
-
-
diff --git a/inst/tests/test-rbind.r b/tests/testthat/test-rbind.r
similarity index 92%
rename from inst/tests/test-rbind.r
rename to tests/testthat/test-rbind.r
index 3d655cd..6309510 100644
--- a/inst/tests/test-rbind.r
+++ b/tests/testthat/test-rbind.r
@@ -91,7 +91,7 @@ test_that("time zones are preserved", {
get_tz <- function(x) attr(as.POSIXlt(x), "tz")
tzs <- c("CET", "UTC")
- for(tz in tzs) {
+ for (tz in tzs) {
start <- data.frame(x = as.POSIXct(dstart, tz = tz))
end <- data.frame(x = as.POSIXct(dstop, tz = tz))
@@ -135,8 +135,8 @@ test_that("multidim arrays ok", {
})
test_that("Array column names preserved", {
- x <- data.frame(hair.color=dimnames(HairEyeColor)[[1]])
- x$obs <- HairEyeColor[,,1]
+ x <- data.frame(hair.color = dimnames(HairEyeColor)[[1]])
+ x$obs <- unclass(HairEyeColor[,,1])
xx1 <- rbind(x, x)
xx2 <- rbind.fill(x, x)
@@ -266,37 +266,36 @@ rbind_time <- function(size,
}
get_rbind_times <- function(...) {
+ # nolint start
rbind_time(10) #warm up/JIT
mdply(.fun = rbind_time, ...)
+ # nolint end
}
if (identical(Sys.getenv("NOT_CRAN"), "true") &&
!identical(Sys.getenv("TRAVIS"), "true")) {
-expect_linear_enough <- function(timings, size=2^10, threshold=0.2) {
+expect_linear_enough <- function(timings, threshold=0.1) {
#expect that no more than `threshold` of a `size` input's runtime is
#accounted for by quadratic behavior
- #predict.lm(type="terms") does strange things w/ built-in intercepts, avoid
- timings <- mutate(timings, intercept=1)
- model <- lm(user.self ~ size + I(size^2) - 1 + intercept, timings)
- p <- predict(model, newdata=data.frame(size=size, intercept=1), type="terms")
- expect_that(p[2] / p[1] < threshold, is_true(), NULL, NULL)
+ model <- lm(I(user.self / size) ~ size, timings)
+ expect_less_than(threshold, summary(model)$coefficients[2,4])
}
test_that("rbind.fill performance linear", {
- timings <- get_rbind_times(data.frame(size = 2^(1:10)),
+ timings <- get_rbind_times(data.frame(size = 2 ^ (1:10)),
classes=c("numeric", "character", "array"))
expect_linear_enough(timings)
})
test_that("rbind.fill performance linear with factors", {
- timings <- get_rbind_times(data.frame(size = 2^(1:10)),
+ timings <- get_rbind_times(data.frame(size = 2 ^ (1:10)),
classes=c("factor"))
expect_linear_enough(timings)
})
test_that("rbind.fill performance linear with times", {
- timings <- get_rbind_times(data.frame(size = 2^(1:10)),
+ timings <- get_rbind_times(data.frame(size = 2 ^ (1:10)),
classes=c("time"))
expect_linear_enough(timings)
})
diff --git a/tests/testthat/test-rename.r b/tests/testthat/test-rename.r
new file mode 100644
index 0000000..9057756
--- /dev/null
+++ b/tests/testthat/test-rename.r
@@ -0,0 +1,113 @@
+# Main-stream cases -----------------------------------
+context("Rename - Expected Usage")
+
+test_that("No match leaves names unchanged", {
+ x <- c(a = 1, b = 2, c = 3, 4)
+ y <- rename(x, c(d = "e"), warn_missing = FALSE)
+
+ expect_equal(names(x), names(y))
+})
+
+test_that("Missing old values result in message", {
+ # This is the same rename operation as above, but should give a message
+ x <- c(a = 1, b = 2, c = 3, 4)
+ expect_message(rename(x, c(d = "e")))
+})
+
+test_that("Single name match makes change", {
+ x <- c(a = 1, b = 2)
+ y <- rename(x, c(b = "c"))
+
+ expect_equal(names(y), c("a", "c"))
+})
+
+test_that("Multiple names correctly changed", {
+ x <- c(a = 1, b = 2, c = 3)
+ y <- rename(x, c("c" = "f", "b" = "e", "a" = "d"))
+
+ expect_equal(names(y), c("d", "e", "f"))
+})
+
+test_that("Empty vectors and lists", {
+ expect_identical(rename(character(), c("c" = "f"), warn_missing = FALSE), character())
+ expect_identical(rename(list(), c("c" = "f"), warn_missing = FALSE), list())
+})
+
+test_that("Renaming lists", {
+ x <- list(a = 1, b = 2, c = 3)
+ y <- rename(x, c("c" = "f", "b" = "e", "a" = "d"))
+ expect_identical(y, list(d = 1, e = 2, f = 3))
+})
+
+# Duplicate Names -----------------------------------
+context("Rename - Duplicates")
+
+# This batch tests the typical renaming scenarios
+test_that("Renaming list with one conflicting variable name - default", {
+ x <- list(a = 1, b = 2, c = 3)
+ replace_list <- c("c" = "f", "b" = "e", "a" = "f")
+ expected_response <- "created duplicates"
+ #The exact match would be: "The plyr::rename operation has created duplicates for the following name\\(s\\): \\(`f`\\)"
+ expect_warning(rename(x = x, replace = replace_list), expected_response)
+})
+test_that("Renaming list with two conflicting variable names - default", {
+ x <- list(a = 1, b = 2, c = 3, d = 4, e = 5)
+ replace_list <- c("c" = "f", "b" = "e", "a" = "f", "d" = "g", "e" = "g")
+ expected_response <- "created duplicates"
+ #The exact match would be: "The plyr::rename operation has created duplicates for the following name\\(s\\): \\(`f`, `g`\\)"
+ expect_warning(rename(x = x, replace = replace_list), expected_response)
+})
+test_that("Renaming list with two conflicting variable names - default", {
+ x <- list(a = 1, b = 2, c = 3, d = 4, e = 5)
+ replace_list <- c("c" = "f", "b" = "e", "a" = "f", "d" = "g", "e" = "g")
+ expected_response <- "created duplicates"
+ #The exact match would be: "The plyr::rename operation has created duplicates for the following name\\(s\\): \\(`f`, `g`\\)"
+ expect_warning(rename(x = x, replace = replace_list), expected_response)
+})
+test_that("Renaming list with an conflicting variable name - without warning", {
+ x <- list(a = 1, b = 2, c = 3)
+ replace_list <- c("c" = "f", "b" = "e", "a" = "f")
+ result <- rename(x = x, replace = replace_list, warn_duplicated = FALSE)
+ expect_identical(result, list(f = 1, e = 2, f = 3))
+})
+
+
+# This batch tests the boundary cases
+test_that("Renaming to the same value", {
+ #One element is renamed to itself
+ x <- list(a = 1, b = 2, c = 3)
+ replace_list <- c("a" = "a")
+ expected_value <- x
+ expect_identical(rename(x = x, replace = replace_list), expected_value)
+})
+test_that("Renaming list with an empty renaming vector", {
+ #No renames are requested (which could happen if the calling code was under a lot of automated code.)
+ x <- list(a = 1, b = 2, c = 3)
+ replace_list <- c()
+ expected_value <- x
+ expect_identical(rename(x = x, replace = replace_list), expected_value)
+})
+test_that("Single Swapping (shouldn't cause problems)", {
+ #Notice how a becomes c, while c becomes f.
+ x <- list(a = 1, b = 2, c = 3)
+ replace_list <- c("c" = "f", "b" = "e", "a" = "c")
+ expected_value <- list(c = 1, e = 2, f = 3)
+ actual_value <- rename(x = x, replace = replace_list)
+ expect_identical(actual_value, expected_value)
+})
+test_that("Double Swapping (shouldn't cause problems)", {
+ #Notice how a becomes c, while c becomes a.
+ x <- list(a = 1, b = 2, c = 3)
+ replace_list <- c("c" = "a", "b" = "z", "a" = "c")
+ expected_value <- list(c = 1, z = 2, a = 3)
+ actual_value <- rename(x = x, replace = replace_list)
+ expect_identical(actual_value, expected_value)
+})
+test_that("Multiple assignments for the same element", {
+ #Notice how it requests to change a to d, e, and f.
+ x <- list(a = 1, b = 2, c = 3)
+ replace_list <- c("a" = "d", "a" = "e", "a" = "f")
+ expected_response <- "The following `from` values were not present in `x`: a, a"
+ expected_value <- list(a = 1, a = 2, a = 3)
+ expect_message(rename(x = x, replace = replace_list), expected_response)
+})
diff --git a/inst/tests/test-replicate.r b/tests/testthat/test-replicate.r
similarity index 99%
rename from inst/tests/test-replicate.r
rename to tests/testthat/test-replicate.r
index 800703c..3b6b3b7 100644
--- a/inst/tests/test-replicate.r
+++ b/tests/testthat/test-replicate.r
@@ -10,6 +10,6 @@ test_that("length of results are correct", {
test_that("name of id column is set", {
df <- rdply(4, function() c(a=1), .id='index')
-
+
expect_equal(names(df), c('index', 'a'))
})
diff --git a/inst/tests/test-revalue.r b/tests/testthat/test-revalue.r
similarity index 96%
rename from inst/tests/test-revalue.r
rename to tests/testthat/test-revalue.r
index a2e3603..dce10c0 100644
--- a/inst/tests/test-revalue.r
+++ b/tests/testthat/test-revalue.r
@@ -33,7 +33,7 @@ test_that("Basic mapping works", {
# revalue doesn't work for numeric vectors
})
-test_that("Mapping with repeated original values works - should use first instance, and give message", {
+test_that("Mapping with repeated original values - uses first instance, and gives message", {
newchr <- c("A2", "B1", "A3", "B1")
expect_message(
expect_identical(mapvalues(chr, c("A1", "A1"), c("B1", "C1")), newchr))
@@ -52,7 +52,7 @@ test_that("Mapping with repeated original values works - should use first instan
expect_identical(mapvalues(num, c(8, 8), c(80, 800)), newnum))
})
-test_that("Mapping with repeated new value works (for factors, levels should be in earliest position)", {
+test_that("Mapping with repeated new value (for factors, levels are in earliest position)", {
newchr <- c("BX", "A1", "BX", "A1")
expect_identical(mapvalues(chr, c("A3", "A2"), c("BX", "BX")), newchr)
expect_identical(revalue(chr, c(A3="BX", A2="BX")), newchr)
diff --git a/inst/tests/test-rply.r b/tests/testthat/test-rply.r
similarity index 94%
rename from inst/tests/test-rply.r
rename to tests/testthat/test-rply.r
index dc0b4f8..b7ae006 100644
--- a/inst/tests/test-rply.r
+++ b/tests/testthat/test-rply.r
@@ -5,7 +5,9 @@ test_that("Side effects for r_ply", {
# Simple function with side effect of incrementing i in an outer environment
# by one
- inc <- function() { i <<- i + 1; invisible(NULL) }
+ inc <- function() {
+ i <<- i + 1; invisible(NULL)
+ }
# For each of the possible counts, check that exactly n side effects are seen
# for various types of invocations of inc: As a statement, as a function call
@@ -44,7 +46,9 @@ test_that("Side effects for rlply", {
# Similar to the test for r_ply, now there is also a return value in incition
# to the side effect
- inc <- function() { i <<- i + 1 }
+ inc <- function() {
+ i <<- i + 1
+ }
# The test now checks, in incition to side effect count, that the returned
# list is correct
@@ -74,9 +78,11 @@ test_that("Side effects for rlply", {
test_that("Side effects for raply", {
counts <- c(0, 1, 5)
-
- inc <- function() { i <<- i + 1 }
-
+
+ inc <- function() {
+ i <<- i + 1
+ }
+
for (n in counts) {
# This is funny. Why does raply(.n, inc) return a named vector only for
# .n == 1?
@@ -86,17 +92,17 @@ test_that("Side effects for raply", {
exp_res <- setNames(nm = 1)
} else
exp_res <- seq_len(n)
-
+
i <- 0
res <- raply(n, inc)
expect_equal(res, exp_res, info="inc")
expect_equal(i, n, info="inc")
-
+
i <- 0
res <- raply(n, inc())
expect_equal(res, exp_res, info="inc()")
expect_equal(i, n, info="inc()")
-
+
i <- 0
res <- raply(n, function() inc())
expect_equal(res, exp_res, info="function() inc()")
@@ -106,26 +112,28 @@ test_that("Side effects for raply", {
test_that("Side effects for rdply", {
counts <- c(0, 1, 5)
-
- inc <- function() { i <<- i + 1; data.frame(i = i) }
-
+
+ inc <- function() {
+ i <<- i + 1; data.frame(i = i)
+ }
+
for (n in counts) {
if (n == 0) {
exp_res <- data.frame()
} else {
exp_res <- data.frame(.n = 1L:n, i = 1L:n, stringsAsFactors = FALSE)
}
-
+
i <- 0
res <- rdply(n, inc)
expect_equal(res, exp_res, info="inc")
expect_equal(i, n, info="inc")
-
+
i <- 0
res <- rdply(n, inc())
expect_equal(res, exp_res, info="inc()")
expect_equal(i, n, info="inc()")
-
+
i <- 0
res <- rdply(n, function() inc())
expect_equal(res, exp_res, info="function() inc()")
diff --git a/inst/tests/test-simplify-df.r b/tests/testthat/test-simplify-df.r
similarity index 96%
rename from inst/tests/test-simplify-df.r
rename to tests/testthat/test-simplify-df.r
index b37b556..c8cbc39 100644
--- a/inst/tests/test-simplify-df.r
+++ b/tests/testthat/test-simplify-df.r
@@ -3,7 +3,7 @@ context("List to data frame")
a <- as.POSIXct(1, origin="2011-01-01")
test_that("classes preserved for atomic scalars", {
- li <- list(a, a+1)
+ li <- list(a, a + 1)
df <- list_to_dataframe(li)
expect_that(df, is_a("data.frame"))
expect_that(class(df[,1]), equals(class(a)))
@@ -21,7 +21,7 @@ test_that("classes preserved for atomic scalars in list of length 1", {
})
test_that("classes preserved for atomic vectors", {
- li <- list(c(a, a+1), c(a+2, a+3))
+ li <- list(c(a, a + 1), c(a + 2, a + 3))
df <- list_to_dataframe(li)
expect_that(df, is_a("data.frame"))
expect_that(nrow(df), equals(2))
@@ -30,7 +30,7 @@ test_that("classes preserved for atomic vectors", {
})
test_that("classes preserved for atomic vectors in list of length 1", {
- li <- list(c(a, a+1))
+ li <- list(c(a, a + 1))
df <- list_to_dataframe(li)
expect_that(df, is_a("data.frame"))
expect_that(nrow(df), equals(1))
@@ -39,7 +39,7 @@ test_that("classes preserved for atomic vectors in list of length 1", {
})
test_that("classes preserved for data.frames", {
- li <- list(data.frame(V1=a, V2=a+1), data.frame(V1=a+2, V2=a+3))
+ li <- list(data.frame(V1=a, V2=a + 1), data.frame(V1=a + 2, V2=a + 3))
df <- list_to_dataframe(li)
expect_that(df, is_a("data.frame"))
expect_that(nrow(df), equals(2))
@@ -135,10 +135,10 @@ test_that("matrices converted to data frames, without id column", {
test_that("matrices converted to data frames, with id column", {
mat <- matrix(1:20, ncol = 4)
colnames(mat) <- letters[1:4]
-
+
li <- list(a = mat, b = mat)
df <- plyr:::list_to_dataframe(li, id_name = "my_id")
-
+
expect_equal(nrow(df), 2 * nrow(mat))
expect_equal(names(df), c("my_id", "a", "b", "c", "d"))
expect_equal(df$my_id, rep(c("a", "b"), c(5, 5)))
@@ -147,10 +147,10 @@ test_that("matrices converted to data frames, with id column", {
test_that("matrices converted to data frames, with id column as factor", {
mat <- matrix(1:20, ncol = 4)
colnames(mat) <- letters[1:4]
-
+
li <- list(a = mat, b = mat)
df <- list_to_dataframe(li, id_name = "my_id", id_as_factor = TRUE)
-
+
expect_equal(nrow(df), 2 * nrow(mat))
expect_equal(names(df), c("my_id", "a", "b", "c", "d"))
expect_equal(levels(df$my_id), c("a", "b"))
diff --git a/inst/tests/test-split-data-frame.r b/tests/testthat/test-split-data-frame.r
similarity index 100%
rename from inst/tests/test-split-data-frame.r
rename to tests/testthat/test-split-data-frame.r
diff --git a/inst/tests/test-split-indices.r b/tests/testthat/test-split-indices.r
similarity index 70%
rename from inst/tests/test-split-indices.r
rename to tests/testthat/test-split-indices.r
index 53d5b26..69b7cc4 100644
--- a/inst/tests/test-split-indices.r
+++ b/tests/testthat/test-split-indices.r
@@ -8,6 +8,14 @@ test_that("index expands if n too small", {
expect_equal(split_indices(1:10, 5), as.list(1:10))
})
+test_that("n is optional in split indices", {
+ x <- sample(100)
+ a <- split_indices(x)
+ b <- split_indices(x, 100)
+
+ expect_equal(a, b)
+})
+
test_that("succeeds for large number of groups", {
i <- 2097142
expect_equal(length(split_indices(seq_len(i), i)), i)
diff --git a/inst/tests/test-split-labels.r b/tests/testthat/test-split-labels.r
similarity index 100%
rename from inst/tests/test-split-labels.r
rename to tests/testthat/test-split-labels.r
diff --git a/inst/tests/test-summarise.r b/tests/testthat/test-summarise.r
similarity index 75%
rename from inst/tests/test-summarise.r
rename to tests/testthat/test-summarise.r
index 2dd5b62..f1f6ad1 100644
--- a/inst/tests/test-summarise.r
+++ b/tests/testthat/test-summarise.r
@@ -10,7 +10,7 @@ test_that("summarise creates correct names", {
df <- summarise(mtcars, x = cyl, y = vs)
expect_that(names(df), equals(c("x", "y")))
- # df <- summarise(mtcars, mean(cyl), mean(vs))
- # expect_that(names(df), equals("x", "y"))
+ df <- summarise(mtcars, mean(cyl), mvs = mean(vs))
+ expect_that(names(df), equals(c("mean(cyl)", "mvs")))
})
diff --git a/tests/testthat/test-utils.r b/tests/testthat/test-utils.r
new file mode 100644
index 0000000..f80abc8
--- /dev/null
+++ b/tests/testthat/test-utils.r
@@ -0,0 +1,23 @@
+context("Utilities")
+
+test_that("is.discrete", {
+ expect_true(is.discrete(factor(3)))
+ expect_true(is.discrete("3"))
+ expect_true(is.discrete(TRUE))
+ expect_false(is.discrete(3L))
+ expect_false(is.discrete(3.0))
+ expect_false(is.discrete(identity))
+})
+
+test_that("nunique", {
+ expect_equal(nunique(LETTERS), 26)
+ expect_equal(nunique(factor(LETTERS)), 26)
+
+ # Odd behavior, for compatibility reasons:
+ expect_equal(nunique(factor(LETTERS)[1:3]), 26)
+})
+
+test_that("check for formula", {
+ expect_true(is.formula(~a))
+ expect_false(is.formula("a"))
+})
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-plyr.git
More information about the debian-med-commit
mailing list