Skip to content

generic name of variables

2 messages · SAULEAU Erik-André, Brian Ripley

#
On Wed, 7 Jan 2004, SAULEAU Erik-Andr? wrote:

            
Without knowing exactly the pattern, let me guess

nms <- ls(pattern="^m[0-9]+")
sapply(nms, function(m) mean(get(m)))

would do what you want.

As Thomas Lumley often says, it is probably better to use a list rather 
than m1, m2, m4, ....