result_create(conn@ptr, statement) : 结果太大
result_create(conn@ptr, statement) : Result too large
t1_DA <- sqldf("select decile,
count(decile) as count, avg(pred_spent) as avg_pred_spent,
avg(exp(total_spent)) as avg_total_spent,
avg(log(pred_spent)) as ln_avg_pred_spent,
avg(total_spent) as ln_avg_total_spent
from t1
group by decile
order by decile desc")
我正在对一个文件进行线性回归,当我 运行 这部分代码时出现以下错误
Error in result_create(conn@ptr, statement) : Result too large
有什么方法可以克服这个错误吗?
如前所述,默认情况下 sqldf
使用 SQLite 方言,它不支持广泛的数学和统计函数,如 exp
和 log
。不可否认,一个更好的引发消息可以帮助用户调试而不是 结果太大(对于作者,@ggrothendieck 可能是 git issue?)。
但是,为了将这些输出集成到聚合查询中,请考虑在 sqldf 中创建这些列 before 运行。使用 transform
或 within
进行简单的新列分配,而无需使用 $
分配方法不断引用数据框。
t1 <- transform(t1, exp_total_spent = exp(total_spent),
log_pred_spent = log10(log_pred_spent)
)
# ALTERNATIVE
t1 <- within(t1, {exp_total_spent <- exp(total_spent)
log_pred_spent <- log10(log_pred_spent)
})
t1_DA <- sqldf("select decile,
count(decile) as count,
avg(pred_spent) as avg_pred_spent,
avg(exp_total_spent) as avg_total_spent,
avg(log_pred_spent) as ln_avg_pred_spent,
avg(total_spent) as ln_avg_total_spent
from t1
group by decile
order by decile desc")
t1_DA <- sqldf("select decile,
count(decile) as count, avg(pred_spent) as avg_pred_spent,
avg(exp(total_spent)) as avg_total_spent,
avg(log(pred_spent)) as ln_avg_pred_spent,
avg(total_spent) as ln_avg_total_spent
from t1
group by decile
order by decile desc")
我正在对一个文件进行线性回归,当我 运行 这部分代码时出现以下错误
Error in result_create(conn@ptr, statement) : Result too large
有什么方法可以克服这个错误吗?
如前所述,默认情况下 sqldf
使用 SQLite 方言,它不支持广泛的数学和统计函数,如 exp
和 log
。不可否认,一个更好的引发消息可以帮助用户调试而不是 结果太大(对于作者,@ggrothendieck 可能是 git issue?)。
但是,为了将这些输出集成到聚合查询中,请考虑在 sqldf 中创建这些列 before 运行。使用 transform
或 within
进行简单的新列分配,而无需使用 $
分配方法不断引用数据框。
t1 <- transform(t1, exp_total_spent = exp(total_spent),
log_pred_spent = log10(log_pred_spent)
)
# ALTERNATIVE
t1 <- within(t1, {exp_total_spent <- exp(total_spent)
log_pred_spent <- log10(log_pred_spent)
})
t1_DA <- sqldf("select decile,
count(decile) as count,
avg(pred_spent) as avg_pred_spent,
avg(exp_total_spent) as avg_total_spent,
avg(log_pred_spent) as ln_avg_pred_spent,
avg(total_spent) as ln_avg_total_spent
from t1
group by decile
order by decile desc")