Movatterモバイル変換


[0]ホーム

URL:


Skip to contents

Using the datefixR Shiny App

Source:vignettes/shiny_app.Rmd
shiny_app.Rmd
library(datefixR)

Introduction

ThedatefixR package provides a user-friendly Shiny appthat allows users to standardize messy date data using a graphical userinterface (GUI). This is particularly useful for researchers, dataanalysts, and anyone working with datasets containing inconsistentlyformatted dates who prefer not to use R code directly.

The app supports the same powerful date parsing capabilities as thecoredatefixR 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 installedautomatically withdatefixR. This design choice allows thecore package to be installed on secure systems where these packagesmight not be permitted.

Required dependencies: -DT - for interactive datatables -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 thisand offer to install them automatically.

Theme Options

The app supports two visual themes:

# Default datefixR theme (recommended)fix_date_app(theme="datefixR")# Standard Shiny themefix_date_app(theme="none")

Step-by-Step Usage Guide

1. File Upload

  • Click theBrowse button in the left sidebar
  • Select either a CSV (.csv) or Excel (.xlsx) file
  • The file will be automatically uploaded and processed
  • ClickRefresh to display the uploaded data

2. Column Selection

After uploading your file:

  • Review the data in theResults tab
  • In the left sidebar, check boxes will appear for each column
  • Select the columns containing date data that need to bestandardized
  • 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 areprovided

Month Imputation

  • Options: 1-12, or NA
  • Default: 7 (July)
  • Purpose: What month to use when only year isprovided

Format Assumption

  • Options: “dmy” (day-month-year) or “mdy”(month-day-year)
  • Default: “dmy”
  • Purpose: How to interpret ambiguous numeric dateslike “01/02/2023”

4. Processing and Review

  • ClickRefresh after selecting columns and settingpreferences
  • The processed data will appear in theResultstab
  • Review the standardized dates to ensure they meet yourexpectations
  • All date columns will now be in YYYY-MM-DD format

5. Download Results

  • Click theDownload button to save your processeddata
  • The file will be saved as “fixed.csv”
  • All selected date columns will be standardized in the output

Advanced Features

File Format Support

The app automatically detects and handles:

  • CSV files: Comma-separated values with automaticencoding detection
  • Excel files: Both .xlsx and .xls formats, reads thefirst worksheet

Error Handling

If the app encounters problematic dates:

  • Error messages will appear in the R console
  • The problematic row and date value will be identified
  • Processing will stop, allowing you to review and correct thedata

Data Privacy

Important Security Note: When using online hostingplatforms (like shinyapps.io), your uploaded files are temporarilystored on the hosting platform’s servers. While no data should be storedpersistently, use discretion with sensitive data. For maximum security,run the app locally.

Example Workflow

Here’s a complete example of using the app:

  1. Prepare your data: Create a CSV file with messydates

    id,event_date,follow_up1,"02/03/21","April 2021"2,"15-Dec-2020","2021"3,"2020/05/01","May 15 2021"
  2. Launch and configure:

  3. 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
  4. Download results: Clean, standardized date dataready for analysis

Troubleshooting

Common Issues

App won’t start: - Ensure all dependencies areinstalled - Try runninginstall.packages(c("DT", "shiny", "readxl", "htmltools"))

File won’t upload: - Check file format (only .csvand .xlsx supported) - Ensure file size is reasonable (< 100MBrecommended) - Verify file isn’t corrupted

Dates not parsing correctly: - Review your formatassumption (dmy vs mdy) - Check for unusual date formats in your data -Consider pre-cleaning obviously problematic entries

Download not working: - Ensure you’ve selected atleast one date column - Try refreshing the processed data first - Checkbrowser download settings

Performance Considerations

  • File Size: The app handles files up to severalthousand rows efficiently
  • Processing Time: Complex date parsing may take afew seconds for large datasets
  • Memory Usage: Keep file sizes reasonable (<100MB) for optimal performance

For the latest updates and to report issues, visit thedatefixR GitHubrepository.


[8]ページ先頭

©2009-2025 Movatter.jp