[med-svn] [r-cran-reshape2] 01/08: New upstream version 1.4.2

Andreas Tille tille at debian.org
Mon Nov 7 18:25:58 UTC 2016


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository r-cran-reshape2.

commit 93b2917620ee18ae6e224ebc87f29c1f8d665bc4
Author: Andreas Tille <tille at debian.org>
Date:   Mon Nov 7 18:57:38 2016 +0100

    New upstream version 1.4.2
---
 DESCRIPTION                | 15 ++++++-------
 LICENSE                    |  2 +-
 MD5                        | 56 +++++++++++++++++++++++-----------------------
 NAMESPACE                  |  4 +++-
 R/RcppExports.R            |  2 +-
 R/data.r                   | 16 +++++--------
 R/melt.r                   |  5 +++++
 R/reshape.r                |  4 +++-
 README.md                  |  4 ++--
 inst/CITATION              |  2 +-
 man/add_margins.Rd         |  3 ++-
 man/cast.Rd                |  5 +++--
 man/colsplit.Rd            |  3 ++-
 man/french_fries.Rd        |  5 +++--
 man/guess_value.Rd         |  3 ++-
 man/margins.Rd             |  3 ++-
 man/melt.Rd                |  7 +++---
 man/melt.array.Rd          | 15 +++++++------
 man/melt.data.frame.Rd     | 12 +++++-----
 man/melt.default.Rd        | 12 +++++-----
 man/melt.list.Rd           |  8 +++----
 man/melt_check.Rd          |  3 ++-
 man/parse_formula.Rd       |  3 ++-
 man/recast.Rd              |  3 ++-
 man/smiths.Rd              |  5 +++--
 man/tips.Rd                |  5 +++--
 src/RcppExports.cpp        | 30 +++++++++++--------------
 src/melt.cpp               | 31 +++++++++++++------------
 tests/testthat/test-melt.r | 41 +++++++++++++++++++++++++++++++++
 29 files changed, 181 insertions(+), 126 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 9b7b180..cc0cfaf 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,20 +1,19 @@
 Package: reshape2
-Type: Package
-Title: Flexibly reshape data: a reboot of the reshape package.
-Version: 1.4
+Title: Flexibly Reshape Data: A Reboot of the Reshape Package
+Version: 1.4.2
 Author: Hadley Wickham <h.wickham at gmail.com>
 Maintainer: Hadley Wickham <h.wickham at gmail.com>
-Description: Reshape lets you flexibly restructure and
-    aggregate data using just two functions: melt and cast.
+Description: Flexibly restructure and aggregate data using just two
+    functions: melt and 'dcast' (or 'acast').
 URL: https://github.com/hadley/reshape
 BugReports: https://github.com/hadley/reshape/issues
 LinkingTo: Rcpp
 Imports: plyr (>= 1.8.1), stringr, Rcpp
-Roxygen: list(wrap = FALSE)
 Suggests: testthat (>= 0.8.0), lattice
 License: MIT + file LICENSE
 LazyData: true
-Packaged: 2014-04-23 12:12:47 UTC; hadley
+RoxygenNote: 5.0.1.9000
 NeedsCompilation: yes
+Packaged: 2016-10-21 19:43:35 UTC; hadley
 Repository: CRAN
-Date/Publication: 2014-04-23 16:34:12
+Date/Publication: 2016-10-22 12:17:37
diff --git a/LICENSE b/LICENSE
index 02969bc..eb54e63 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,2 +1,2 @@
-YEAR: 2008-2014
+YEAR: 2008-2016
 COPYRIGHT HOLDER: Hadley Wickham
diff --git a/MD5 b/MD5
index 25baeab..dbc02c5 100644
--- a/MD5
+++ b/MD5
@@ -1,43 +1,43 @@
-80e1197e01ef035042dac55a858ffd16 *DESCRIPTION
-c7ea166b434ab74f81ce002ea5d87b07 *LICENSE
-49177420adf56e29f1e6df797daa4fd7 *NAMESPACE
-a41923a0c3dd9c64e173686355479ae1 *R/RcppExports.R
+a0e1a31261ff65c15a21c969b20f17d1 *DESCRIPTION
+581827da3959cce1750fb90f1eb98ec8 *LICENSE
+fd8905f0d53ec03f481bb242dd7a0e75 *NAMESPACE
+6a66deb772bc6ecf31259089b452bc7c *R/RcppExports.R
 4aa84b2006ec919fb46cd7b352952916 *R/cast.r
-827ca227c89be29638317fd0cf09810d *R/data.r
+125db94629ec768bc540371316d2eb80 *R/data.r
 64787f81028fc99b399324ea1e20d388 *R/formula.r
 be60b82da1500a97b295ec2eedcbcecd *R/helper-colsplit.r
 b88bd2b7d2e7ee40cefcf33e6b5145ab *R/helper-guess-value.r
 6d720bda805d2903c1cde371a58611ba *R/helper-margins.r
-8ac26acd4388cd90ba9d4601def9c412 *R/melt.r
+7636e967448a7846e6697cb899c63fb4 *R/melt.r
 3b203639e96d72299d6dc7ea6e97a179 *R/recast.r
-56fe864c06a775eaaa3c4c39aa013415 *R/reshape.r
+703f0e7f087a046299646b6519cd9ded *R/reshape.r
 2eb44aae9ad8d328afda7379086ec877 *R/utils.r
-1269f00722e814c55c8b4052cf5a03c4 *README.md
+7af06153ad01e703989e7cb74d4bac0e *README.md
 11d6f343f97ca34edc7cb5ad4a174d05 *data/french_fries.rda
 931bb9da3bce71ebcb25ba53c5dcd1e5 *data/smiths.rda
 6a3f0a74f813cd68547e665f42b8a3cb *data/tips.rda
-dd664ad85751a470cf0b7414a1c4c3ec *inst/CITATION
-760d53a13108f2f2688d3f48e0587389 *man/add_margins.Rd
-c3c5e1ece6293a89672a4e67fef1846d *man/cast.Rd
-9825c4f987358217df32f752a52de468 *man/colsplit.Rd
-1d1e6853db07b4f2669f486dd65a4309 *man/french_fries.Rd
-248ac8ff74c1ea6bd6c52ff30eddf82f *man/guess_value.Rd
-b43ca4b201b16cde1e6737099b122ac7 *man/margins.Rd
-62667b517bb67a06e4696238870260e3 *man/melt.Rd
-75d51e9dd1a45b61820847572250e081 *man/melt.array.Rd
-5a4f897301abfee4dcbf5a5fba1450a4 *man/melt.data.frame.Rd
-0a774f8518bb460b63853938ed3d75ce *man/melt.default.Rd
-8f56b5e3474bef6f0db9e5be64900d29 *man/melt.list.Rd
-f409237630dbedee29ed98ff30f7b782 *man/melt_check.Rd
-69465c7fa930c098d075dabc149576af *man/parse_formula.Rd
-c1e35b037d85d451808f9397a774c1d6 *man/recast.Rd
-56ebb0580192b71037dbc17b4963283d *man/smiths.Rd
-207d6da0290afadcdc17c39c5a30c456 *man/tips.Rd
+12120b1cc03a4e744f04421ef99ebc48 *inst/CITATION
+a38ffdf6acadf4af0515ae5b642afc2c *man/add_margins.Rd
+0ce186534dd3131776b4915d4773451f *man/cast.Rd
+3471d7f0ce1a7d0e2745b625d7465644 *man/colsplit.Rd
+741274273dd9f76bb7603c94b82ac138 *man/french_fries.Rd
+508cde91850c9962138209d2d2736c9f *man/guess_value.Rd
+5eb1133a68f4fa75fac9963e0402148e *man/margins.Rd
+c03f16a2ea0f929fdd8375ca23895f99 *man/melt.Rd
+9d052c6c754bb0c3a09116d8ca2a0b93 *man/melt.array.Rd
+62d1f360a21de36c15b44c99e6ed5579 *man/melt.data.frame.Rd
+6276fd04f602353d70bf0b90d28796de *man/melt.default.Rd
+b6eae2d0f433f7b270dd580eeb21aa61 *man/melt.list.Rd
+6c5033a09e652c0f66d0b3bfcc44f28b *man/melt_check.Rd
+2a0c5e81d167736049f0ff2c586a553a *man/parse_formula.Rd
+56793152e808c20eaeb1425f3ec44663 *man/recast.Rd
+bea4b7e556999fd38bd34d73ec6eee76 *man/smiths.Rd
+dfe78bdd1430ab01bf4df7fbb4bc0086 *man/tips.Rd
 2dbab2cfefc21e9c3d9b44d60b2cc771 *po/R-ko.po
 15d543bb8dc1c303c8f4a9f54ef767ef *po/R-reshape.pot
-be0ef27f9591d078302bf4f59bb0d03f *src/RcppExports.cpp
-e47f1fa8028888545cc472508db272df *src/melt.cpp
+c72ed0dd7a3c63042e0ce76c6017ed8f *src/RcppExports.cpp
+bffca058114bf27e81d160715d2e3b6a *src/melt.cpp
 cbd1f6d4b546516421d74e001e092bbb *tests/testthat.R
 396d0d07c44ceeb304947ec03c2286d1 *tests/testthat/test-cast.r
 c450402fc64e0d1a35d777917ff93ad0 *tests/testthat/test-margins.r
-3b67b1ae2f6541474bfcf563381d3c78 *tests/testthat/test-melt.r
+b8d8c0d166945ea0c6ac52a6444146f6 *tests/testthat/test-melt.r
diff --git a/NAMESPACE b/NAMESPACE
index 1f140ab..2cc6fd9 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,4 +1,4 @@
-# Generated by roxygen2 (4.0.0): do not edit by hand
+# Generated by roxygen2: do not edit by hand
 
 S3method(melt,array)
 S3method(melt,data.frame)
@@ -15,4 +15,6 @@ export(recast)
 import(plyr)
 import(stringr)
 importFrom(Rcpp,evalCpp)
+importFrom(stats,setNames)
+importFrom(utils,type.convert)
 useDynLib(reshape2)
diff --git a/R/RcppExports.R b/R/RcppExports.R
index 16a4e80..18b8e38 100644
--- a/R/RcppExports.R
+++ b/R/RcppExports.R
@@ -1,4 +1,4 @@
-# This file was generated by Rcpp::compileAttributes
+# Generated by using Rcpp::compileAttributes() -> do not edit by hand
 # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
 
 melt_dataframe <- function(data, id_ind, measure_ind, variable_name, value_name, measure_attributes, factorsAsStrings, valueAsFactor) {
diff --git a/R/data.r b/R/data.r
index 59aecb2..cac4360 100644
--- a/R/data.r
+++ b/R/data.r
@@ -19,11 +19,9 @@
 #' }
 #'
 #' @docType data
-#' @name french_fries
-#' @usage data(french_fries)
 #' @format A data frame with 696 rows and 9 variables
 #' @keywords datasets
-NULL
+"french_fries"
 
 #' Demo data describing the Smiths.
 #'
@@ -31,12 +29,9 @@ NULL
 #' introductory vignette.
 #'
 #' @docType data
-#' @name smiths
-#' @usage data(smiths)
 #' @format A data frame with 2 rows and 5 variables
 #' @keywords datasets
-NULL
-
+"smiths"
 
 #' Tipping data
 #'
@@ -61,9 +56,8 @@ NULL
 #' @references Bryant, P. G. and Smith, M (1995) \emph{Practical Data
 #'   Analysis: Case Studies in Business Statistics}.  Homewood, IL: Richard D.
 #'   Irwin Publishing:
-#' @docType data
-#' @name tips
-#' @usage data(tips)
 #' @format A data frame with 244 rows and 7 variables
 #' @keywords datasets
-NULL
+"tips"
+
+
diff --git a/R/melt.r b/R/melt.r
index 72d5060..b823ed4 100644
--- a/R/melt.r
+++ b/R/melt.r
@@ -117,6 +117,11 @@ melt.data.frame <- function(data, id.vars, measure.vars, variable.name = "variab
   id.ind <- match(vars$id, names(data))
   measure.ind <- match(vars$measure, names(data))
 
+  ## Return early if we have id.ind but no measure.ind
+  if (!length(measure.ind)) {
+    return(data[id.vars])
+  }
+
   ## Get the attributes if common, NULL if not.
   args <- normalize_melt_arguments(data, measure.ind, factorsAsStrings)
   measure.attributes <- args$measure.attributes
diff --git a/R/reshape.r b/R/reshape.r
index 3eb2328..e2b89b2 100644
--- a/R/reshape.r
+++ b/R/reshape.r
@@ -1,3 +1,5 @@
 ##' @importFrom Rcpp evalCpp
+##' @importFrom stats setNames
+##' @importFrom utils type.convert
 ##' @useDynLib reshape2
-NULL
\ No newline at end of file
+NULL
diff --git a/README.md b/README.md
index 98fd459..9d63980 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 
 [![Build Status](https://travis-ci.org/hadley/reshape.png)](https://travis-ci.org/hadley/reshape)
 
-Reshape2 is a reboot of the reshape package. It's been over five years since the first release of reshape, and in that time I've learned a tremendous amount about R programming, and how to work with data in R. Reshape2 uses that knowledge to make a new package for reshaping data that is much more focussed and much much faster.
+Reshape2 is a reboot of the reshape package. It's been over five years since the first release of reshape, and in that time I've learned a tremendous amount about R programming, and how to work with data in R. Reshape2 uses that knowledge to make a new package for reshaping data that is much more focused and much much faster.
 
 This version improves speed at the cost of functionality, so I have renamed it to `reshape2` to avoid causing problems for existing users.  Based on user feedback I may reintroduce some of these features.
 
@@ -39,4 +39,4 @@ This work has been generously supported by BD (Becton Dickinson).
 ## Installation
 
 * Get the released version from cran: `install.packages("reshape2")`
-* Get the dev version from github: `devtools::install_github("hadley/reshape2")`
+* Get the dev version from github: `devtools::install_github("hadley/reshape")`
diff --git a/inst/CITATION b/inst/CITATION
index 222edde..2efd19f 100644
--- a/inst/CITATION
+++ b/inst/CITATION
@@ -1,4 +1,4 @@
-citHeader("To cite reshape in publications use:")
+citHeader("To cite reshape2 in publications use:")
 
 citEntry(entry = "Article",
   title        = "Reshaping Data with the {reshape} Package",
diff --git a/man/add_margins.Rd b/man/add_margins.Rd
index 07e1e96..f0e6dcc 100644
--- a/man/add_margins.Rd
+++ b/man/add_margins.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/helper-margins.r
 \name{add_margins}
 \alias{add_margins}
 \title{Add margins to a data frame.}
diff --git a/man/cast.Rd b/man/cast.Rd
index aab4bf9..25382ee 100644
--- a/man/cast.Rd
+++ b/man/cast.Rd
@@ -1,8 +1,9 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/cast.r
 \name{cast}
-\alias{acast}
 \alias{cast}
 \alias{dcast}
+\alias{acast}
 \title{Cast functions
 Cast a molten data frame into an array or data frame.}
 \usage{
diff --git a/man/colsplit.Rd b/man/colsplit.Rd
index 79bf465..2c8b477 100644
--- a/man/colsplit.Rd
+++ b/man/colsplit.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/helper-colsplit.r
 \name{colsplit}
 \alias{colsplit}
 \title{Split a vector into multiple columns}
diff --git a/man/french_fries.Rd b/man/french_fries.Rd
index 9340844..7343010 100644
--- a/man/french_fries.Rd
+++ b/man/french_fries.Rd
@@ -1,11 +1,12 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/data.r
 \docType{data}
 \name{french_fries}
 \alias{french_fries}
 \title{Sensory data from a french fries experiment.}
 \format{A data frame with 696 rows and 9 variables}
 \usage{
-data(french_fries)
+french_fries
 }
 \description{
 This data was collected from a sensory experiment conducted at Iowa State
diff --git a/man/guess_value.Rd b/man/guess_value.Rd
index 1d20f9a..a28563e 100644
--- a/man/guess_value.Rd
+++ b/man/guess_value.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/helper-guess-value.r
 \name{guess_value}
 \alias{guess_value}
 \title{Guess name of value column}
diff --git a/man/margins.Rd b/man/margins.Rd
index d20c69f..5c4cbea 100644
--- a/man/margins.Rd
+++ b/man/margins.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/helper-margins.r
 \name{margins}
 \alias{margins}
 \title{Figure out margining variables.}
diff --git a/man/melt.Rd b/man/melt.Rd
index 6acc368..a9e81f8 100644
--- a/man/melt.Rd
+++ b/man/melt.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/melt.r
 \name{melt}
 \alias{melt}
 \title{Convert an object into a molten data frame.}
@@ -8,11 +9,11 @@ melt(data, ..., na.rm = FALSE, value.name = "value")
 \arguments{
 \item{data}{Data set to melt}
 
+\item{...}{further arguments passed to or from other methods.}
+
 \item{na.rm}{Should NA values be removed from the data set? This will
 convert explicit missings to implicit missings.}
 
-\item{...}{further arguments passed to or from other methods.}
-
 \item{value.name}{name of variable used to store values}
 }
 \description{
diff --git a/man/melt.array.Rd b/man/melt.array.Rd
index 07e3291..9f171b0 100644
--- a/man/melt.array.Rd
+++ b/man/melt.array.Rd
@@ -1,8 +1,9 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/melt.r
 \name{melt.array}
 \alias{melt.array}
-\alias{melt.matrix}
 \alias{melt.table}
+\alias{melt.matrix}
 \title{Melt an array.}
 \usage{
 \method{melt}{array}(data, varnames = names(dimnames(data)), ...,
@@ -21,14 +22,14 @@
 
 \item{...}{further arguments passed to or from other methods.}
 
+\item{na.rm}{Should NA values be removed from the data set? This will
+convert explicit missings to implicit missings.}
+
 \item{as.is}{if \code{FALSE}, the default, dimnames will be converted
 using \code{\link{type.convert}}. If \code{TRUE}, they will be left
 as strings.}
 
 \item{value.name}{name of variable used to store values}
-
-\item{na.rm}{Should NA values be removed from the data set? This will
-convert explicit missings to implicit missings.}
 }
 \description{
 This code is conceptually similar to \code{\link{as.data.frame.table}}
@@ -47,8 +48,8 @@ melt(a)
 \seealso{
 \code{\link{cast}}
 
-Other melt.methods: \code{\link{melt.data.frame}};
-  \code{\link{melt.default}}; \code{\link{melt.list}}
+Other melt methods: \code{\link{melt.data.frame}},
+  \code{\link{melt.default}}, \code{\link{melt.list}}
 }
 \keyword{manip}
 
diff --git a/man/melt.data.frame.Rd b/man/melt.data.frame.Rd
index fa5d3c1..ffdbb38 100644
--- a/man/melt.data.frame.Rd
+++ b/man/melt.data.frame.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/melt.r
 \name{melt.data.frame}
 \alias{melt.data.frame}
 \title{Melt a data frame into form suitable for easy casting.}
@@ -18,12 +19,12 @@ position) or string (variable name)If blank, will use all non id.vars}
 
 \item{variable.name}{name of variable used to store measured variable names}
 
-\item{value.name}{name of variable used to store values}
+\item{...}{further arguments passed to or from other methods.}
 
 \item{na.rm}{Should NA values be removed from the data set? This will
 convert explicit missings to implicit missings.}
 
-\item{...}{further arguments passed to or from other methods.}
+\item{value.name}{name of variable used to store values}
 
 \item{factorsAsStrings}{Control whether factors are converted to character
 when melted as measure variables. When \code{FALSE}, coercion is forced if
@@ -46,9 +47,8 @@ melt(ChickWeight, id=2:4)
 \seealso{
 \code{\link{cast}}
 
-Other melt.methods: \code{\link{melt.array}},
-  \code{\link{melt.matrix}}, \code{\link{melt.table}};
-  \code{\link{melt.default}}; \code{\link{melt.list}}
+Other melt methods: \code{\link{melt.array}},
+  \code{\link{melt.default}}, \code{\link{melt.list}}
 }
 \keyword{manip}
 
diff --git a/man/melt.default.Rd b/man/melt.default.Rd
index 7456282..b74e8b6 100644
--- a/man/melt.default.Rd
+++ b/man/melt.default.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/melt.r
 \name{melt.default}
 \alias{melt.default}
 \title{Melt a vector.
@@ -9,11 +10,11 @@ For vectors, makes a column of a data frame}
 \arguments{
 \item{data}{vector to melt}
 
+\item{...}{further arguments passed to or from other methods.}
+
 \item{na.rm}{Should NA values be removed from the data set? This will
 convert explicit missings to implicit missings.}
 
-\item{...}{further arguments passed to or from other methods.}
-
 \item{value.name}{name of variable used to store values}
 }
 \description{
@@ -23,9 +24,8 @@ For vectors, makes a column of a data frame
 \seealso{
 \code{\link{melt}}, \code{\link{cast}}
 
-Other melt.methods: \code{\link{melt.array}},
-  \code{\link{melt.matrix}}, \code{\link{melt.table}};
-  \code{\link{melt.data.frame}}; \code{\link{melt.list}}
+Other melt methods: \code{\link{melt.array}},
+  \code{\link{melt.data.frame}}, \code{\link{melt.list}}
 }
 \keyword{manip}
 
diff --git a/man/melt.list.Rd b/man/melt.list.Rd
index 215821e..2865c9b 100644
--- a/man/melt.list.Rd
+++ b/man/melt.list.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/melt.r
 \name{melt.list}
 \alias{melt.list}
 \title{Melt a list by recursively melting each component.}
@@ -30,9 +31,8 @@ melt(list(list(1:3), 1, list(as.list(3:4), as.list(1:2))))
 \seealso{
 \code{\link{cast}}
 
-Other melt.methods: \code{\link{melt.array}},
-  \code{\link{melt.matrix}}, \code{\link{melt.table}};
-  \code{\link{melt.data.frame}}; \code{\link{melt.default}}
+Other melt methods: \code{\link{melt.array}},
+  \code{\link{melt.data.frame}}, \code{\link{melt.default}}
 }
 \keyword{manip}
 
diff --git a/man/melt_check.Rd b/man/melt_check.Rd
index 9f0c61a..52ae744 100644
--- a/man/melt_check.Rd
+++ b/man/melt_check.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/melt.r
 \name{melt_check}
 \alias{melt_check}
 \title{Check that input variables to melt are appropriate.}
diff --git a/man/parse_formula.Rd b/man/parse_formula.Rd
index ed4499a..109d372 100644
--- a/man/parse_formula.Rd
+++ b/man/parse_formula.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/formula.r
 \name{parse_formula}
 \alias{parse_formula}
 \title{Parse casting formulae.}
diff --git a/man/recast.Rd b/man/recast.Rd
index 361b189..7b06449 100644
--- a/man/recast.Rd
+++ b/man/recast.Rd
@@ -1,4 +1,5 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/recast.r
 \name{recast}
 \alias{recast}
 \title{Recast: melt and cast in a single step}
diff --git a/man/smiths.Rd b/man/smiths.Rd
index 93772cc..07d8d35 100644
--- a/man/smiths.Rd
+++ b/man/smiths.Rd
@@ -1,11 +1,12 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/data.r
 \docType{data}
 \name{smiths}
 \alias{smiths}
 \title{Demo data describing the Smiths.}
 \format{A data frame with 2 rows and 5 variables}
 \usage{
-data(smiths)
+smiths
 }
 \description{
 A small demo dataset describing John and Mary Smith.  Used in the
diff --git a/man/tips.Rd b/man/tips.Rd
index c965aac..278a669 100644
--- a/man/tips.Rd
+++ b/man/tips.Rd
@@ -1,11 +1,12 @@
-% Generated by roxygen2 (4.0.0): do not edit by hand
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/data.r
 \docType{data}
 \name{tips}
 \alias{tips}
 \title{Tipping data}
 \format{A data frame with 244 rows and 7 variables}
 \usage{
-data(tips)
+tips
 }
 \description{
 One waiter recorded information about each tip he received over a
diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp
index d9644e0..7054619 100644
--- a/src/RcppExports.cpp
+++ b/src/RcppExports.cpp
@@ -1,4 +1,4 @@
-// This file was generated by Rcpp::compileAttributes
+// Generated by using Rcpp::compileAttributes() -> do not edit by hand
 // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
 
 #include <Rcpp.h>
@@ -9,21 +9,17 @@ using namespace Rcpp;
 List melt_dataframe(const DataFrame& data, const IntegerVector& id_ind, const IntegerVector& measure_ind, String variable_name, String value_name, SEXP measure_attributes, bool factorsAsStrings, bool valueAsFactor);
 RcppExport SEXP reshape2_melt_dataframe(SEXP dataSEXP, SEXP id_indSEXP, SEXP measure_indSEXP, SEXP variable_nameSEXP, SEXP value_nameSEXP, SEXP measure_attributesSEXP, SEXP factorsAsStringsSEXP, SEXP valueAsFactorSEXP) {
 BEGIN_RCPP
-    SEXP __sexp_result;
-    {
-        Rcpp::RNGScope __rngScope;
-        Rcpp::traits::input_parameter< const DataFrame& >::type data(dataSEXP );
-        Rcpp::traits::input_parameter< const IntegerVector& >::type id_ind(id_indSEXP );
-        Rcpp::traits::input_parameter< const IntegerVector& >::type measure_ind(measure_indSEXP );
-        Rcpp::traits::input_parameter< String >::type variable_name(variable_nameSEXP );
-        Rcpp::traits::input_parameter< String >::type value_name(value_nameSEXP );
-        Rcpp::traits::input_parameter< SEXP >::type measure_attributes(measure_attributesSEXP );
-        Rcpp::traits::input_parameter< bool >::type factorsAsStrings(factorsAsStringsSEXP );
-        Rcpp::traits::input_parameter< bool >::type valueAsFactor(valueAsFactorSEXP );
-        List __result = melt_dataframe(data, id_ind, measure_ind, variable_name, value_name, measure_attributes, factorsAsStrings, valueAsFactor);
-        PROTECT(__sexp_result = Rcpp::wrap(__result));
-    }
-    UNPROTECT(1);
-    return __sexp_result;
+    Rcpp::RObject rcpp_result_gen;
+    Rcpp::RNGScope rcpp_rngScope_gen;
+    Rcpp::traits::input_parameter< const DataFrame& >::type data(dataSEXP);
+    Rcpp::traits::input_parameter< const IntegerVector& >::type id_ind(id_indSEXP);
+    Rcpp::traits::input_parameter< const IntegerVector& >::type measure_ind(measure_indSEXP);
+    Rcpp::traits::input_parameter< String >::type variable_name(variable_nameSEXP);
+    Rcpp::traits::input_parameter< String >::type value_name(value_nameSEXP);
+    Rcpp::traits::input_parameter< SEXP >::type measure_attributes(measure_attributesSEXP);
+    Rcpp::traits::input_parameter< bool >::type factorsAsStrings(factorsAsStringsSEXP);
+    Rcpp::traits::input_parameter< bool >::type valueAsFactor(valueAsFactorSEXP);
+    rcpp_result_gen = Rcpp::wrap(melt_dataframe(data, id_ind, measure_ind, variable_name, value_name, measure_attributes, factorsAsStrings, valueAsFactor));
+    return rcpp_result_gen;
 END_RCPP
 }
diff --git a/src/melt.cpp b/src/melt.cpp
index 3d811bc..aafbe72 100644
--- a/src/melt.cpp
+++ b/src/melt.cpp
@@ -43,6 +43,8 @@ SEXP rep_(SEXP x, int n) {
       DO_REP(CPLXSXP, Rcomplex, COMPLEX);
     case RAWSXP:
       DO_REP(RAWSXP, Rbyte, RAW);
+    case VECSXP:
+      DO_REP(VECSXP, SEXP, STRING_PTR);
     default: {
       stop("Unhandled RTYPE");
       return R_NilValue;
@@ -94,6 +96,8 @@ SEXP rep_each_(SEXP x, int n) {
       DO_REP_EACH(CPLXSXP, Rcomplex, COMPLEX);
     case RAWSXP:
       DO_REP_EACH(RAWSXP, Rbyte, RAW);
+    case VECSXP:
+      DO_REP_EACH(VECSXP, SEXP, STRING_PTR);
     default: {
       stop("Unhandled RTYPE");
       return R_NilValue;
@@ -208,23 +212,22 @@ List melt_dataframe(const DataFrame& data,
                     bool valueAsFactor) {
 
   int nrow = data.nrows();
-  int ncol = data.size();
 
   CharacterVector data_names = as<CharacterVector>(data.attr("names"));
 
-  // We only melt data.frames that contain only atomic elements
-  for (int i = 0; i < ncol; ++i) {
-    if (!Rf_isVectorAtomic(data[i])) {
-      stop("Can't melt data.frames with non-atomic columns");
-    }
-  }
-
   int n_id = id_ind.size();
   debug(Rprintf("n_id == %i\n", n_id));
 
   int n_measure = measure_ind.size();
   debug(Rprintf("n_measure == %i\n", n_measure));
 
+  // Don't melt if the value variables are non-atomic
+  for (int i = 0; i < n_measure; ++i) {
+    if (!Rf_isVectorAtomic(data[measure_ind[i]])) {
+      stop("Can't melt data.frames with non-atomic 'measure' columns");
+    }
+  }
+
   // The output should be a data.frame with:
   // number of columns == number of id vars + 'variable' + 'value',
   // with number of rows == data.nrow() * number of value vars
@@ -249,6 +252,7 @@ List melt_dataframe(const DataFrame& data,
       REP(STRSXP);
       REP(CPLXSXP);
       REP(RAWSXP);
+      REP(VECSXP);
       default: { stop("internal error: unnhandled vector type in REP"); }
     }
   }
@@ -267,12 +271,11 @@ List melt_dataframe(const DataFrame& data,
   output[n_id + 1] = concatenate(data, measure_ind, factorsAsStrings);
   if (!Rf_isNull(measure_attributes)) {
     SET_ATTRIB(output[n_id + 1], measure_attributes);
-  }
-
-  // Set the object bit explicitly to make sure that the 'value' is properly
-  // interpreted as a factor
-  if (valueAsFactor) {
-    SET_OBJECT(output[n_id + 1], 1);
+    // we also need to make sure the OBJECT bit is set for other 'object' types
+    // see: http://stackoverflow.com/questions/24059460/melt-data-frame-changes-behavior-how-posixct-columns-are-printed
+    // if we've entered this code block, the measure_attributes has been
+    // populated because all value variables have identical attributes
+    SET_OBJECT(output[n_id + 1], OBJECT(data[measure_ind[0]]));
   }
 
   // Make the List more data.frame like
diff --git a/tests/testthat/test-melt.r b/tests/testthat/test-melt.r
index 4d97275..1e4c4a1 100644
--- a/tests/testthat/test-melt.r
+++ b/tests/testthat/test-melt.r
@@ -173,3 +173,44 @@ test_that("factorsAsStrings behaves as expected", {
   expect_identical( class(m$value), "character" )
 
 })
+
+test_that("melt.data.frame behaves when there are no measure variables", {
+
+  df <- data.frame(x='a', y='b', z='c')
+  m <- melt(df)
+  expect_identical(df, m)
+  m <- melt(df, id.vars = "x", measure.vars = NULL)
+  expect_identical(df["x"], m)
+
+})
+
+test_that("melt.data.frame preserves OBJECT bit on e.g. POSIXct", {
+  t.wide <- data.frame(product=letters[1:5],
+                       result=c(2, 4, 0, 0, 1),
+                       t1=as.POSIXct("2014-05-26") + seq(0, 10800, length.out=5),
+                       t2=as.POSIXct("2014-05-27") + seq(0, 10800, length.out=5),
+                       t3=as.POSIXct("2014-05-28") + seq(0, 10800, length.out=5))
+
+  library(reshape2)
+  object_bit_set <- function(x) {
+    grepl("\\[OBJ", capture.output(.Internal(inspect(x)))[1])
+  }
+  t.long <- melt(t.wide, measure.vars=c("t1", "t2", "t3"), value.name="time")
+  expect_true(object_bit_set(t.long$time))
+})
+
+test_that("melt.data.frame allows for lists in the set of id variables", {
+  df <- data.frame(x = 1:5)
+  df$y <- list(
+    data.frame(),
+    new.env(),
+    as.name("foo"),
+    1,
+    as.POSIXct(Sys.Date())
+  )
+  df$za <- letters[1:5]
+  df$zb <- letters[6:10]
+  df$zc <- letters[11:15]
+  result <- melt(df, id=1:2)
+  expect_identical(result$y[1:5], df$y)
+})

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-reshape2.git



More information about the debian-med-commit mailing list