每15分钟绘制一次积分

时间:2020-12-27 02:26:34

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:

我有一个文本文件,其中包含数字(浮点类型),表示以秒为单位的时间。我希望每15分钟代表一次出现次数。我的文件样本是:

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...

前900秒(15分钟),有6次出现。我想首先在y轴上绘制该点。然后从900-1800(接下来的15分钟),有4次出现。所以,我想在我的y轴上绘制4。这应该继续......

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.

我知道基本的plot()函数,但我不知道如何每15分钟绘制一次。如果有链接,请引导我访问该链接。

2 个解决方案

#1


1  

Use findInterval():

使用findInterval():

counts <- table(findInterval(x, seq(0, max(x), 900)))
counts

1 2 3 
6 4 1 

It's easy to plot:

情节很容易:

plot(counts)

每15分钟绘制一次积分

#2


0  

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.

以Andrie的答案为基础。您可以将绘图(计数,类型='p')添加到绘图点或绘图(计数,类型='l')以绘制连接线。如果要为计数绘制曲线,则需要使用?lm或?nls对其进行建模。

#1


1  

Use findInterval():

使用findInterval():

counts <- table(findInterval(x, seq(0, max(x), 900)))
counts

1 2 3 
6 4 1 

It's easy to plot:

情节很容易:

plot(counts)

每15分钟绘制一次积分

#2


0  

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.

以Andrie的答案为基础。您可以将绘图(计数,类型='p')添加到绘图点或绘图(计数,类型='l')以绘制连接线。如果要为计数绘制曲线,则需要使用?lm或?nls对其进行建模。