I have a large data set (~140000 values) that I would like to make plots for.
The data is composed of a value, a time stamp and an ID number. The ID number uses the time stamp to bin the values into a time duration (ex. every 10 minutes, 1 hour,etc...). Each value timestamped within the first 10 minutes is assigned a 1. This continues until all values are assigned a group number. This gives me over a thousand unique group ID numbers.
The plot is a histogram with the x axis having value ranges (ex. 1:2,2:3,3:4,etc..). The Y axis is the proportion of the values sampled that fall into each range.
The code I have been using to generate a plot for all the data look like this:
ggplot(ICICLICKS1, aes(x=ICIms))+
geom_histogram(aes(y=..count../sum(..count..)),binwidth=2) +
scale_x_continuous(limits=c(1.5,140), breaks = seq(0,140,5))+
scale_y_continuous(limits=c(0.0,0.25))+
geom_vline(xintercept=c(10,50))+
xlab("ICI(ms)")+
ylab("Proportion")+
ggtitle("Histogram of Porpoise Inter-click Intervals")
My end goal is to have a plot for each 10 minute period. Since that would be a few thousand plots I need to find a way to get R to run the code, plotting all values with ID number 1, export plot, plot all values with ID number 2, export plot, etc... until all the ID numbers have been run. Is there a way to write a loop or some other piece of code t accomplish this?