Recently I have started learning R because of the powerful number of tools that are part of the R eco-system for data analysis.
Previously, doing a histogram of a time-series was a painstaking process.
I'm happy to announce that today, I have discovered the power of the hist function for time data as POSIXlt class data.
Here is the basic code:
# Read the data in
Data <- read.csv("~/MyDataSource.csv", header=FALSE)
# Convert the timestamps from the csv file into POSIXlt date time structure
Data$V1 <- as.POSIXlt(Data$V1, format="%Y-%m-%d %H:%M:%S")
# Display the histogram
hist(Data$V1, breaks="hour", xlab="Date / Time")
This assumes that the first column contains date and time data formatted like: 2016-02-05 09:04:24.967 while reading the dates in from the default timezone of the system.
Showing posts with label Data Analysis. Show all posts
Showing posts with label Data Analysis. Show all posts
Time Series Histogram Generation in R Studio
Thanks R Studio for making my life easier!
Subscribe to:
Posts (Atom)
