Changelog
Source:NEWS.md
unpivotr 0.6.3
CRAN release: 2023-01-22
- Make compatible with dplyr v1.1.0 (#58 @DavisVaughan)
- Implement
as_cells.matrix()(#52 @billdenney) - Allow behead() to work on grouped data (#46 @billdenney)
- Add as_cells.matrix (#41 @billdenney)
unpivotr 0.6.1
CRAN release: 2020-08-03
- Fix concatenation of
NULLPOSIXct(dates) (#39 @romainfrancois)
unpivotr 0.6.0
CRAN release: 2020-05-08
- Change
"NNW"to"up-left"etc. Compass directions still work, but the built-in datasetpurposehas different names and documentation will gradually change to the new terms. - Patches for upcoming upstream changes
unpivotr 0.5.0
CRAN release: 2019-01-02
New features
-
behead_if()is for tiered headers within the same row or column. It takes filter functions similarly todplyr::filter()to decide which cells to treat as headers, and can be applied more than once to the same row or column of headers until every tier has been dealt with. -
merge_rows()andmerge_cols()combines header text when it is split over multiple cells.
Other changes
-
behead(),enhead(),partition()andrectify()give a more informative error message for non-distinct cells, for example when trying to pass cells from more than one sheet to these functions (@gregrs-uk, #15).
unpivotr 0.4.0
CRAN release: 2018-06-26
This version makes some big breaking changes for the sake of a more intuitive grammar. It comes with much more documentation in the online book Spreadsheet Munging Strategies.
The main new workhorses:
-
behead()takes one level of headers from a pivot table and make it part of the data. Chain this function to gradually strip every level of header away until you have tidy data. -
spatter()is a data-type aware version oftidyr::spread()and is a common final step. -
partition()breaks up small-multiples on a single sheet, so you can handle them individually. -
rectify()visualises the cells in the console as they would look in a spreadsheet.
Breaking changes
The previous version can be installed as follows.
devtools::install_version("unpivotr", version = "0.3.1", repos = "http://cran.us.r-project.org")- The family of functions
NNW()etc. has been removed in favour of the verbosejoin_header(), which has itself been renamed toenhead()to suggest its similarity tobehead()(though they are not complements). -
enhead()(formerlyjoin_header()now follows the tidyverse convention offctfor ‘factor’ andordfor ‘ordered factor’. -
enhead()(formerlyjoin_header()) now usescol_namesandrow_namesas arguments instead ofcolnamesandrownames, for consistency with tidyr.
New features
-
behead()is takes one level of headers from a pivot table and make it part of the data. Think of it liketidyr::gather(), except that it works when there is more than one row of headers (or more than one column of row-headers), and it only works on tables that have first come throughenhead()(formerlyjoin_header()ortidyxl::xlsx_cells(). -
rectify()displays cells as though in a spreadsheet, rather than in the ‘melted’ form ofenhead()(formerlyjoin_header()) andtidyxl::xlsx_cells(). This is useful for understanding the structure of a pivot table as a human, when planning how to unpivot it. A print method is available to render large datasets in the browser or the RStudio viewer pane. -
partition()divides a grid of cells into partitions containing individual tables. Give it the corner cells of each table on a spreadsheet. -
pack()packs cells values from separate columns per data type into one list-column.unpack()is the complement. -
isolate_sentinels()move sentinel values into a separate column, leavingNAbehind (orNULLfor list-columns). -
spatter()is liketidyr::spread(), but preserves mixed data types. -
enhead()(formerlyjoin_header()) now returns adata_typecolumn that names the column that contains the value of a cell, similar totidyxl::xlsx_cells(). -
enhead()(formerlyjoin_header()now follows the tidyverse convention offctfor ‘factor’ andordfor ‘ordered factor’. -
enhead()(formerlyjoin_header()) gains adrop = TRUEargument to control whether to discard cells that don’t have a matching header (e.g. ones that are left of the leftmost header inenhead(x, y, "NNW")). -
justify()moves one set of cells to the same positions as another set. This is useful when header cells aren’t at the corner of the cells they describle. Put the header cells intojustify(), along with cells that are at the corner. - New vignette ‘worked-examples’ of common tasks when munging spreadsheets.
- The ‘small-multiples’ vignette has been refactored to use the new features.
-
purpose(built-in dataset) gains a new list-membersmall-multiples.
unpivotr 0.3.1
CRAN release: 2018-01-20
- Performance improvements to
tidy_table(). - Fixed a CRAN test on some platforms.
unpivotr 0.3.0
CRAN release: 2017-12-03
- Made compatible with tidyxl version 1.0.0 (avoids
dplyr::distinct(), which doesn’t handle list columns). - Updated to use the new
dplyr/rlangcombination instead of the olddplyr/lazyevalone.
unpivotr 0.2.1
CRAN release: 2017-07-02
This release overhauls the tidy_table() function of unpivotr to preserve the original data types of table cells and to support HTML tables.
-
tidytable()has been renamedtidy_table().tidytable()is an error, rather than a deprecation warning, becausetidy_table()is so different from before. - There is a new
tidy_table()method and vignette for HTML. - There is no
tidy_table()method for matrices. Convert matrices to data.frames first, choosing what to do with row and column names. -
tidy_table()returns only relevant columns, according to the data types of the columns in the given data frame. It usestibble::type_sum()to determine the column type and to name the columns, so whereas characters used to be returned in a column calledcharacter, they are now returned in a column calledchr. The full list of column names is in?tidy_tableand ischr,cplx,cplx,dbl,fctr,int,lgl,list. The columnsfctrandlistare list-columns, where each element is itself a list. This means that factors with different levels are kept separate. For HTML tables, anhtmlcolumn is returned containing the standalone HTML of each cell. - Both
rownameandcolnamearguments totidy_table()now default toFALSE. - All functions consistently return a
tibble. - Some error messages are more helpful.