I have the following example data frame x
id val
a 1
a 2
a 3
b 2
b 4
b 9
I have a simple function that I apply while doing my SAC. Something like,
f.x <- function(x){
cat(x$id,"\n")
}
Note, all that I’m trying to do is print out the grouping term. This function is called using ddply as follows
ddply(x,.(id),f.x)
However, when I run this I get integer outputs which I suspect are indices of a list. How do I get the actual grouping term within f.x, in this case ‘a’ & ‘b’?
Thanks much in advance.
If every thing you want to do is print you should use d_ply.
In ddply (d_ply) actual argument passed to function (f.x here) is data.frame (subset of x data.frame), so you should modify your f.x function.