Applies restore_day_month() to the columns that look dominated by Excel
serials, leaving the rest of the frame alone. Column selection is a
heuristic, controlled by pmin: it is the price of working from imported
values. If the original workbook is available, unexcel_xlsx() selects
columns from the file's own date formatting instead, and
excel_date_columns() reports that selection for a frame imported by any
other reader.
Arguments
- df
A data frame.
- pmin
Minimum fraction of a column's values that must be in-range whole numbers before the column is treated as serials.
- cols
Optional column names or indices to restrict the operation to. Supplying this turns off the
pminscan, so nothing is selected by guesswork; pair it withexcel_date_columns()for a fully determined result.- low_serial, high_serial
Bounds, inclusive, on what counts as a plausible serial. The defaults span roughly 1954 to 2078.
- year_window
Years that a converted serial may resolve to. A serial landing outside the window is left alone.
- date_system
"1900"or"1904"; seeexcel_date_system().- order
"dm"or"md"; seeserial_to_day_month().- output
"numeric"or"character"; seeserial_to_day_month()."character"preserves a trailing zero, so a value typed as3.10survives as"3.10"rather than3.1.- origin_mode
Deprecated.
"1900"and"1904"are passed todate_system."auto"re-enables the 0.1.0 behaviour of picking the date system by comparing candidate dates againstref_date, with a warning: that comparison is a heuristic and can shift every restored value by four years and a day.- ref_date
Reference date used only by
origin_mode = "auto".
Examples
df <- data.frame(a = c(45746, 45823), b = c(1.2, 3.4))
fix_serial_columns(df)
#> a b
#> 1 30.3 1.2
#> 2 15.6 3.4
# Name the columns yourself and nothing is inferred
fix_serial_columns(df, cols = "a")
#> a b
#> 1 30.3 1.2
#> 2 15.6 3.4
