给stat_smooth添加一个偏移量 [英] Adding an offset to stat_smooth

查看:100
本文介绍了给stat_smooth添加一个偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个数据集,我必须对某些数据进行转换以适合曲线拟合。我使用ggplot2来绘制它,并且可以在转换的数据上使用stat_smooth来获得拟合,但是然后想要将结果叠加在正确的数据点上。



作为玩具的例子,假设我有
$ b $ qplot(1:10,1:10)+ stat_smooth(formula = y + 1〜x,method =lm)



但我想将stat_smooth行向下移一位(除了从公式中取+1)。这可能吗?

解决方案

有时候,事情可能会非常明显:

<$ (公式=(y + 1)-1〜x,method =lm)

I'm working with a dataset where I have to transform some data for a curve fit. I'm plotting it using ggplot2, and can use stat_smooth on the transformed data to get the fit, but then want to overlay the result on the correct datapoints.

As a toy example, let's say I had

qplot(1:10, 1:10)+stat_smooth(formula=y+1~x, method="lm")

But I want to shift the stat_smooth line down by one (other than by taking the +1 out of the formula). Is this possible?

解决方案

Sometimes things can be very obvious :

qplot(1:10, 1:10)+stat_smooth(formula=(y+1)-1~x, method="lm")

If you can raise it 1 by adding 1 to y, you can lower it 1 by substracting 1 from y. ;-)

这篇关于给stat_smooth添加一个偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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