Skip to content
Prev 268005 / 398502 Next

enclosing with() in a function

Hi All,

I want to enclose with() in a function mean_on_element. Obviously, it
is not working. The problem is how to specify the element name with a
function body. Does anybody have any suggestion? Thanks!
[1] 5.5
+   with(data, mean(elem_name))
+ }
[1] NA
Warning message:
In mean.default(elem_name) :
  argument is not numeric or logical: returning NA