列中R中的线性插值
我有一个名为“费率”的列的表。此列包括缺失值。 我需要计算线性函数,在基于先前的现有值和遵循缺失值之后的值计算中缺失值的情况下,替换值之间的间隔应相等。
例如,列“费率”包括值: 0,66 na na na 0,77 0,75 0,79 na na 0,79
,我需要获得一个新的列,其中Na值将以我上述方式替换为R。
I have a table with column called 'rates'. This column include missing values.
I need to calculate linear function where missing values are calculated based on previous existing value and a value that follows the missing value, and there should be an equal interval between replaced missing values.
For example, column 'rates' include values:
0,66
Na
Na
Na
0,77
0,75
0,79
Na
Na
0,79
And I need to get a new column where Na values will be replaced in R the way I described above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从
Zoo
软件包中使用Na.Approx
。根据文档的功能:代码:
在2022-07-05创建的 reprex软件包(v2.0.1)
You could use
na.approx
from thezoo
package. The function according to document:Code:
Created on 2022-07-05 by the reprex package (v2.0.1)