This will do it, but we're all still curious why...
The problem you're having is that call doesn't take a full function call like you're giving it; instead, just give it the name of the function as the first parameter, and then the parameters you want to use, quoting anything you don't want evaluated.
> fit$call <- call("lm", Sepal.Length ~ Petal.Length,
data=quote("iris"), foo=NULL)
> fit
Call:
lm(Sepal.Length ~ Petal.Length, data = "iris", foo = NULL)
Coefficients:
(Intercept) Petal.Length
4.3066 0.4089
This is what miceadds probably should be doing, though with do.call to actually execute it; if it were, it would be recording the call as you want. See https://stackoverflow.com/a/17026386/210673 for one example.
You might be able to make your own function that calls lm.cluster and does what you want, see below for an example. After looking into it, it would be tricky to fix lm.cluster, at least for the data piece, the formula piece would be an easy fix. For data it's harder to handle because the function could get passed an expression rather than the name of an object.
lm.special <- function(formula, data, ... ) {
lm(formula=formula, data=data, ...)
}
lm.special2 <- function(formula, data.name) {
cl <- call("lm.special", formula=formula, data=as.name(data.name))
out <- eval(cl)
out$call <- cl
out
}
> lm(Sepal.Length ~ Petal.Length, iris)
Call:
lm(formula = Sepal.Length ~ Petal.Length, data = iris)
Coefficients:
(Intercept) Petal.Length
4.3066 0.4089
> lm.special(Sepal.Length ~ Petal.Length, iris)
Call:
lm(formula = formula, data = data)
Coefficients:
(Intercept) Petal.Length
4.3066 0.4089
> lm.special2(Sepal.Length ~ Petal.Length, "iris")
Call:
lm.special(formula = Sepal.Length ~ Petal.Length, data = iris)
Coefficients:
(Intercept) Petal.Length
4.3066 0.4089