Displaying 1 result from an estimated 1 matches for "f_diff".
Did you mean:
_diff
2013 Aug 30
0
ddply for comparing simulation results
This might do it:
> lhs=c('a','a','a','b')
> rhs=c('a','b','b','b')
>
>
> # function to determine differences
> f_diff <- function(l, r){
+ t_l <- table(l)
+ t_r <- table(r)
+ # compare 'l' to 'r'
+ sapply(names(t_l), function(x){
+ if (is.na(t_r[x])) return(t_l[x])
+ t_l[x] - t_r[x]
+ })
+ }
>
> f_diff(lhs, rhs)
a.a b.b
2 -2
>
Jim Holtman
D...