I'm applying ddply to the following data frame. The point is to apply ecdf function to yearly_test_count value to rows that have the same country.
> 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
This is the script I used:
house_total_year_ecdf <- ddply(test, c("country"), mutate,
ecdf_val = ecdf(yearly_test_count)(yearly_test_count)*length(yearly_test_count))
But I received the following error:
Error in eval(substitute(expr), envir, enclos) :
object 'yearly_test_count' not found
==================================================================
I tried using the function ecdf alone with yearly_test_count column and it works:
ecdf(test$yearly_test_count)(test$yearly_test_count)*length(test$yearly_test_count)
Anyone has any idea why this doesn't work when using ddply?
This is weird since the script worked before, now I run the script again and encounter the mentioned error. I'm not sure if this issue is related to different in versions of R or versions of the package?
Any help is much appreciated ! :)