- Make tests compatible with recent versions of tzdata (CRAN)
- 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)
- Fix for upstream changes in rlang (#49 thanks @lionel-)
- Fix concatenation of
NULL
POSIXct
(dates) (#39 @romainfrancois)
- Change
"NNW"
to"up-left"
etc. Compass directions still work, but the built-in datasetpurpose
has different names and documentation will gradually change to the new terms. - Patches for upcoming upstream changes
- Patch for tibble
.name_repair
compatibility (#2144 @krlmlr) - Patch to switch to
tidyselect
fromdplyr
functions.
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.
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).
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.
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 offct
for 'factor' andord
for 'ordered factor'.enhead()
(formerlyjoin_header()
) now usescol_names
androw_names
as arguments instead ofcolnames
andrownames
, for consistency with tidyr.
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, leavingNA
behind (orNULL
for list-columns).spatter()
is liketidyr::spread()
, but preserves mixed data types.enhead()
(formerlyjoin_header()
) now returns adata_type
column that names the column that contains the value of a cell, similar totidyxl::xlsx_cells()
.enhead()
(formerlyjoin_header()
now follows the tidyverse convention offct
for 'factor' andord
for 'ordered factor'.enhead()
(formerlyjoin_header()
) gains adrop = TRUE
argument 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
.
- No longer depends on the data.table package.
- Performance improvements to
tidy_table()
. - Fixed a CRAN test on some platforms.
- Made compatible with tidyxl version 1.0.0 (avoids
dplyr::distinct()
, which doesn't handle list columns). - Updated to use the new
dplyr
/rlang
combination instead of the olddplyr
/lazyeval
one.
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_table
and ischr
,cplx
,cplx
,dbl
,fctr
,int
,lgl
,list
. The columnsfctr
andlist
are list-columns, where each element is itself a list. This means that factors with different levels are kept separate. For HTML tables, anhtml
column is returned containing the standalone HTML of each cell.- Both
rowname
andcolname
arguments totidy_table()
now default toFALSE
. - All functions consistently return a
tibble
. - Some error messages are more helpful.
- Fixed breakages introduced by dplyr 0.6.
- Moved images from
inst/extdata
tovignettes
.
- Bumped version to match tidyxl, which is now more mature.
- Updated README and vignettes to use the new tidyxl api.
- Added a
NEWS.md
file to track changes to the package.