R-beta: port of bicreg package to R?
Thomas Lumley
thomas at biostat.washington.edu
Wed Sep 23 18:05:48 CEST 1998
On Tue, 22 Sep 1998, Malcolm Gillies wrote:
> R version: 0.62.1 (June 15, 1998)
>
> I just very naively attempted to grab the 'bicreg' package for
> Bayesian model selection from the StatLib library, and get it running
> under R.
>
> I've hit a brick wall very quickly, and as an R novice I'm not sure
> where to go next.
>
> The relevant lines of code in 'bicreg' would appear to be
>
> [...]
> cdf <-cbind.data.frame(y=y,x)
> mm <- model.matrix(formula(cdf),data=cdf)[,-1,drop=F]
> [...]
>
> It appears to me that applying formula() to the matrix is a no-no. Is
> this an incompatibility between Splus and R?
Here's a formula method for data.frame that you can put in the function to
allow formula(cdf)
formula.data.frame<- function (df)
{
nm <- sapply(names(df), as.name)
lhs <- nm[1]
if (length(nm) > 1) {
rhs <- nm[-1]
}
else {
rhs <- nm[1]
lhs <- NULL
}
ff <- parse(text = paste(lhs, paste(rhs, collapse = "+"),
sep = "~"))
eval(ff)
}
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list