Reputation: 3851
I have a text file having the numbers(of float type) which represents time in seconds. I wish to represent the number of occurances every 15 minutes. The sample of my file is:
0.128766
2.888977
25.087900
102.787657
400.654768
879.090874
903.786754
1367.098789
1456.678567
1786.564569
1909.567567
for first 900 seconds(15 minutes), there are 6 occurances. I want to plot that point on y axis first. Then from 900-1800(next 15 minutes), there are 4 occurances. So, i want to plot 4 on my y-axis next. This should go on...
I know the basic plot() function, but i don't know how to plot every 15 minutes. If there is a link present, please guide me to that link.
Upvotes: 1
Views: 189
Reputation: 1595
To build on Andrie's answer. You can add plot(counts, type = 'p')
to plot points or plot(counts, type = 'l')
to plot a connected line. If you want to plot a curve for the counts you would need to model it using ?lm
or ?nls
.
Upvotes: 0
Reputation: 179428
Use findInterval()
:
counts <- table(findInterval(x, seq(0, max(x), 900)))
counts
1 2 3
6 4 1
It's easy to plot:
plot(counts)
Upvotes: 1