Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用geom_平滑强制截取_R_Ggplot2 - Fatal编程技术网

R 使用geom_平滑强制截取

R 使用geom_平滑强制截取,r,ggplot2,R,Ggplot2,我希望在两个变量之间制作一个比较图,重叠两个产品的geom_smooth()。测量理论迫使起点a(x=0;y=0),但当我绘制图形时,用geom_smooth()创建的蓝色回归线不会经过坐标(0;0)。该geom_smooth()是否可能固定在第一个点(0;0)的特定定义坐标处 代码如下: library(ggplot2) RawData <- data.frame( "Time" = c(0, 3, 6, 9, 24, 30, 34, 48, 57, 0, 3,

我希望在两个变量之间制作一个比较图,重叠两个产品的
geom_smooth()
。测量理论迫使起点a
(x=0;y=0)
,但当我绘制图形时,用
geom_smooth()
创建的蓝色回归线不会经过坐标
(0;0)
。该
geom_smooth()
是否可能固定在第一个点(0;0)的特定定义坐标处

代码如下:

library(ggplot2)

RawData <- data.frame(
  "Time" = c(0, 3, 6, 9, 24, 30, 34, 48, 57, 0, 3, 6, 9, 24, 30, 34, 48, 57), 
  "Curing" = c(0, 11.36, 31.81, 34.09, 75, 86.36, 97.7, 100, 100, 0, 77.5, 92, 95, 98, 100, 100, 100, 100), 
  "Grade" = c("Product A", "Product A", "Product A", "Product A", "Product A", "Product A", "Product A", "Product A", "Product A", "Product B", "Product B", "Product B", "Product B", "Product B", "Product B", "Product B", "Product B", "Product B"))

attach(RawData)

Graph <- ggplot(data=RawData, aes(x=`Time`, y=`Curing`, col=Grade)) + 
  geom_point(aes(color = Grade), shape = 1, size = 2.5) + 
  geom_smooth(level=0.50, span = 0.9999999999) +
  scale_color_manual(values=c('#f92410','#644196')) + 
  xlab("Tempo espresso in ore") + 
  ylab("% Di reticolazione") + 
  labs(color='') + 
  theme(legend.justification = "top")

Graph + geom_rug(aes(color = Grade))
库(ggplot2)

RawData您可以使用以下代码为数据集中的每个组的点
(0,0)
赋予非常高的权重:

library(ggplot2)

RawData <- data.frame("Time" = c(0, 3, 6, 9, 24, 30, 34, 48, 57, 0, 3, 6, 9, 24, 30, 34, 48, 57), "Curing" = c(0, 11.36, 31.81, 34.09, 75, 86.36, 97.7, 100, 100, 0, 77.5, 92, 95, 98, 100, 100, 100, 100), "Grade" = c("Product A", "Product A", "Product A", "Product A", "Product A", "Product A", "Product A", "Product A", "Product A", "Product B", "Product B", "Product B", "Product B", "Product B", "Product B", "Product B", "Product B", "Product B"))

RawData$weight  = ifelse(RawData$Time==0, 1000, 1)

Graph <- ggplot(data=RawData, aes(x=`Time`, y=`Curing`, col=Grade)) + geom_point(aes(color = Grade), shape = 1, size = 2.5) + 
  geom_smooth(aes(weight=weight), level=0.50, span = 0.9999999999) + 
  scale_color_manual(values=c('#f92410','#644196')) + xlab("Tempo espresso in ore") + ylab("% Di reticolazione") + labs(color='') + theme(legend.justification = "top")
Graph + geom_rug(aes(color = Grade))
库(ggplot2)

RawData线圈有个错误,我已经修好了。非常感谢你!它能工作,而且很好。你帮了我很多!!