Introduction
The datefixR
package provides a user-friendly Shiny app
that allows users to standardize messy date data using a graphical user
interface (GUI). This is particularly useful for researchers, data
analysts, and anyone working with datasets containing inconsistently
formatted dates who prefer not to use R code directly.
The app supports the same powerful date parsing capabilities as the
core datefixR
functions, including:
- Multiple date formats and separators
- International month names in 9 languages
- Custom imputation strategies for missing date components
- Excel and CSV file processing
- Batch processing of multiple date columns
Installation and Setup
Prerequisites
The Shiny app requires additional dependencies that are not installed
automatically with datefixR
. This design choice allows the
core package to be installed on secure systems where these packages
might not be permitted.
Required dependencies: - DT
- for interactive data
tables - shiny
- for the web application framework -
readxl
- for reading Excel files - htmltools
-
for HTML generation
Launching the App
To start the app, simply run:
If any required dependencies are missing, the app will detect this and offer to install them automatically.
Theme Options
The app supports two visual themes:
# Default datefixR theme (recommended)
fix_date_app(theme = "datefixR")
# Standard Shiny theme
fix_date_app(theme = "none")
Step-by-Step Usage Guide
1. File Upload
- Click the Browse button in the left sidebar
- Select either a CSV (.csv) or Excel (.xlsx) file
- The file will be automatically uploaded and processed
- Click Refresh to display the uploaded data
2. Column Selection
After uploading your file:
- Review the data in the Results tab
- In the left sidebar, check boxes will appear for each column
- Select the columns containing date data that need to be standardized
- Multiple columns can be selected simultaneously
3. Imputation Settings
Configure how missing date components should be handled:
Day of Month Imputation
- Options: 1-28, or NA
- Default: 1 (first day of month)
- Purpose: What day to use when only month/year are provided
Advanced Features
File Format Support
The app automatically detects and handles:
- CSV files: Comma-separated values with automatic encoding detection
- Excel files: Both .xlsx and .xls formats, reads the first worksheet
Example Workflow
Here’s a complete example of using the app:
-
Prepare your data: Create a CSV file with messy dates
id,event_date,follow_up 1,"02/03/21","April 2021" 2,"15-Dec-2020","2021" 3,"2020/05/01","May 15 2021"
-
Launch and configure:
-
Upload and process:
- Upload your CSV file
- Select “event_date” and “follow_up” columns
- Set day imputation to 15, month imputation to 6
- Click Refresh
Download results: Clean, standardized date data ready for analysis
Troubleshooting
Common Issues
App won’t start: - Ensure all dependencies are
installed - Try running
install.packages(c("DT", "shiny", "readxl", "htmltools"))
File won’t upload: - Check file format (only .csv and .xlsx supported) - Ensure file size is reasonable (< 100MB recommended) - Verify file isn’t corrupted
Dates not parsing correctly: - Review your format assumption (dmy vs mdy) - Check for unusual date formats in your data - Consider pre-cleaning obviously problematic entries
Download not working: - Ensure you’ve selected at least one date column - Try refreshing the processed data first - Check browser download settings
Performance Considerations
- File Size: The app handles files up to several thousand rows efficiently
- Processing Time: Complex date parsing may take a few seconds for large datasets
- Memory Usage: Keep file sizes reasonable (< 100MB) for optimal performance
For the latest updates and to report issues, visit the datefixR GitHub repository.