导出数据框或打印到CSV

时间:2017-06-27 14:43:42

标签: r

我'尝试导出打印到.csv的数据,但无法确定相应的语法/代码。

$this->validate($request, [
    'cameraMac' => 'required|transformUpper'
]);

我可以使用命令for (project in 1:ncol(df)){ i=1 for (digs in c(df[, project])){ total[i,project] = getTotalDigsCost(digs) i = i +1 } } data.frame(average = sapply(total, mean), sd = sapply(total, sd), p95 = sapply(total, function(x) quantile(x,.95)), p20 = sapply(total, function(x) quantile(x,.20)), p80 = sapply(total, function(x) quantile(x,.80))) write_csv(total, "1_R_DigsCostOutput.csv") 导出write_csv(total, 1"1_R-DigsCostOutput.csv"),但我无法识别要导出totalsd等值的内容

思想?

1 个答案:

答案 0 :(得分:0)

感谢Bugle先生和Andrew在上述评论中的帮助,我找到了导出数据框的解决方案:

write_csv(data.frame(average = sapply(total, mean),
                     sd = sapply(total, sd),
                     p95 = sapply(total,function(x) quantile(x,.95)),
                     p20 = sapply(total, function(x) quantile(x,.20)),
                     p80 = sapply(total, function(x) quantile(x,.80))),"1_R_Digs.csv")