在R中逐步回归导入列名

时间:2017-10-05 01:24:40

标签: r regression

我想将从逐步回归过程中选择的变量作为列名导入,这样我的“输出”就具有逐步回归的变量,如下所示。但是,我的代码不会这样做。

我无法理解我在这里做错了什么。有人可以帮帮我吗?

iris$area <- iris$Petal.Length * iris$Petal.Width
iris <- data.table(iris)
mydata <- iris[Species %in% "virginica", list(Sepal.Length,Sepal.Width,Petal.Length,Petal.Width,area)]

fit <- lm(area~., data=mydata)
satis.step <- step(fit, direction="both")
datanew <- iris[Species %in% "virginica", list(Species, paste(attr(satis.step$formula, "term.labels"),collapse = ", ")) ]

输出

我需要输出看起来像:

Species       Sepal.Length     Sepal.Width
------------------------------------------
virginicia         6.3            3.3
virginicia         5.8            2.7

1 个答案:

答案 0 :(得分:0)

我得到了这个。

<style>
/* Chrome, Safari, Opera */
@-webkit-keyframes zoom {
    from
    {
        -webkit-transform: scale(1,1);

    }
    to
    {
        -webkit-transform: scale(1.5,1.5);
    }
}

/* Standard syntax */
@keyframes zoom {
    from
    {
    transform: scale(1,1);
    }
    to
    {
    transform: scale(1.5,1.5);
    }
}


.imgx {
    -webkit-animation: zoom 10s;
    -webkit-animation-fill-mode: forwards;

    animation: zoom 30s;
    animation-fill-mode: forwards;
}
</style>
相关问题