DP13 Match Replace Pattern ReGex
Description
This script is designed to address instances where imported data is presented in a modified format, including date values accompanied by unnecessary time components such as the default 12:00 time. The script employs regular expressions to efficiently eliminate these unnecessary time values, resulting in a refined dataset with only the essential date information. Through the application of regular expressions, the script extracts and retains the date component while discarding the superfluous time details.
Link to the Complete Script in Github
R Script - Match Replace Pattern ReGex
Initial data Date + Time
Code with Regular expression. Take the characters before the first space
1
gsub('([0-9]+) .*', '\\1', df$Int_Date)
Final result: Only date
__
End of Post
This post is licensed under CC BY 4.0 by the author.