我正在将 ddply 应用于以下数据框。关键是将 ecdf 函数应用于 yearly_test_count 值到具有相同国家的行。
> head(test)
country yearly_test_count download_speed
1 AU 1 2.736704
2 AU 6 3.249486
3 AU 6 2.287267
4 AU 6 2.677241
5 AU 6 1.138213
6 AU 6 3.205364
这是我使用的脚本:
house_total_year_ecdf <- ddply(test, c("country"), mutate,
ecdf_val = ecdf(yearly_test_count)(yearly_test_count)*length(yearly_test_count))
但我收到以下错误:
Error in eval(substitute(expr), envir, enclos) :
object 'yearly_test_count' not found
==================================================== =================
我尝试单独使用功能 ecdf 和 yearly_test_count 列,它可以工作:
ecdf(test$yearly_test_count)(test$yearly_test_count)*length(test$yearly_test_count)
任何人都知道为什么在使用 ddply 时这不起作用?
这很奇怪,因为脚本之前工作过,现在我再次运行脚本并遇到提到的错误。我不确定这个问题是否与不同版本的 R 或包的版本有关?
任何帮助深表感谢 !:)