Message-ID: <mlk730pt31ovhpcuill9srv1a3dba7blfs@4ax.com>
Date: 2004-02-18T21:14:13Z
From: Duncan Murdoch
Subject: using names() as a variable in a formula
In-Reply-To: <011a01c3f660$13466660$72180281@jawks2>
On Wed, 18 Feb 2004 15:44:59 -0500, "femke" <femke at geog.umd.edu> wrote
>> v<-variogram(A1~1,loc=~x+y, dataC)
What package is variogram in? The one in spatial takes different
args.
>> v<-variogram(names(dataC[3])~1,loc=~x+y, dataC)
Doing this sort of thing is tricky. Your names(dataC[3]) is a
character string; you want something there that would be interpreted
as a name instead. However, as.name(names(dataC[3])) isn't enough.
I think you need to build up the formula using fairly low level stuff,
something like this:
formula <- as.call(list(as.name('~'), as.name(names(dataC[3])),
quote(1)))
and then do
variogram(formula, ....)
but a formula constructed this way doesn't work in lm(), so it may not
work in variogram either.
Duncan Murdoch