gpt4 book ai didi

r - as.data.frame.default(data): cannot coerce class “” formula“” to a data.frame中的错误

转载 作者:行者123 更新时间:2023-12-03 08:47:50 30 4
gpt4 key购买 nike

我不太确定为什么会收到此错误或其含义。我的数据框称为“数据”。

  library(dplyr)
data %>%
filter(Info==1, Male==1) %>%
lm(CFL_Purchased ~ Male) %>%
summary()

谢谢!

最佳答案

这对我有用:

library(dplyr)

dat <- data.frame(x = rnorm(10000, 4, 3),
y = rnorm(10000, 2, 2))

dat %>%
lm(y ~ x,.) %>%
summary()

Call:
lm(formula = y ~ x, data = .)

Residuals:
Min 1Q Median 3Q Max
-7.5620 -1.3678 -0.0307 1.3625 8.0371

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.952941 0.033064 59.065 <2e-16 ***
x 0.008841 0.006617 1.336 0.182
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.001 on 9998 degrees of freedom
Multiple R-squared: 0.0001785, Adjusted R-squared: 7.852e-05
F-statistic: 1.785 on 1 and 9998 DF, p-value: 0.1815

关于r - as.data.frame.default(data): cannot coerce class “” formula“” to a data.frame中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49778783/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com