Created
November 24, 2015 22:15
-
-
Save Myfanwy/d1f717904a32e3870e00 to your computer and use it in GitHub Desktop.
All the ways I know to get things in the right date/time format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All of my times are in mm/dd/yyyy hh:mm:ss | |
# From a character string (read in from read.csv(stringsAsFactors = FALSE)) | |
# By far the easiest way is with lubridate::mdy_hms() | |
#Ex: | |
options(stringsAsFactors = FALSE) | |
Sys.timezone(location = FALSE) | |
Sys.setenv(TZ = "Pacific/Pitcairn") | |
Sys.timezone() # make sure it took | |
files <- list.files(pattern = "*.csv") #create list of files by character name; change working directory first | |
d <- plyr::adply(files, 1, read.csv) #combine into one big dataframe | |
colnames(d) <- c("DateTimeUTC", "Monitor" , "TagID") | |
d$DateTimeUTC <-mdy_hms(f$DateTimeUTC) # Convert to POSIXct | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment