I'm trying to use ddply to process each row of a dataframe with a function as argument passed to ddply.
The following is a simplified illustration. But I got the error: Error in eval(expr, envir, enclos) : object 'x' not found
> df <- data.frame(standard = c("banana", "apple"), variants = c("xiangjiao", "pingguo"))
>
> df
standard variants
1 banana xiangjiao
2 apple pingguo
> ddply(df, .(x), function(x) { cat("Here is a row: ", x) })
Error in eval(expr, envir, enclos) : object 'x' not found
>
I'm following the example found at For each row in an R dataframe
It looks so straightforward. I assumed the x would stand for the value of each row here.
library(plyr)
ddply(dataFrame, .(x), function(x) { # do stuff })
But it seems that there are still some nuance that I don't know.
Thanks for your help.
Yu