我可以将黄土回归的结果导出到R中吗? [英] Can I export the result from a loess regression out of R?

查看:114
本文介绍了我可以将黄土回归的结果导出到R中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对一些数据进行了黄土回归并绘制了图.问题是我想将黑线和浅红线(见图)导出到excel中.有可能吗?

I have performed a loess regression on some data and plotted it. The problem is I'd like to export the black line and light red line (see figure) into excel. Is it possible?

说明:

我想从黄土回归中导出基础数据,而不是从图中导出.

I want to export the underlying data from the loess regression not the graph.

用于计算它的代码:

ggplot(data, aes(x=bigangle, y=meanz, colour=treatment)) + 
  geom_point(data=df, aes(y = X2/median(df$X2), x=X8),color="red",alpha=.6) +
  geom_smooth(data=df, aes(y = X2/median(df$X2),x=X8),fill="red", colour="black", size=1,alpha=0.4)+
  geom_point(position=position_dodge(0.1),aes(shape=treatment),   # Shape depends on cond
             size = 4,colour="black",fill="black") 

推荐答案

我不确定ggplot2使用的黄土函数,但这是一种提取黄土对象以在Excel中作图的方法:

I am not sure what loess function ggplot2 uses, but here is one way to extract a loess object to graph in Excel:

# fake data
myData <- data.frame("x"=1:100, "y"=rnorm(100))
# loess object
my.loess <- loess(y~x, data=temp)
# get SE
myPred <- predict(my.loess, se=T)
my.output <- data.frame("fitted"=myPred$fit, "SE"=myPred$se.fit)

# write out data
write.csv(my.output, file=<path/filename>.csv)

这篇关于我可以将黄土回归的结果导出到R中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆