关于R作交互作用的示意图的一个小问题,求助

Python017

关于R作交互作用的示意图的一个小问题,求助,第1张

如果要做的话,在公式里面写出来就可以了。A*B表示因素A和B,还有它们的交互作用都包括在分析里,如果要单独写出来交互作用要用A:B。

如果要画出来的话,interaction.plot()可以作出交互效应图,

考查因素之间交互作用是否存在, 比如

>op<-par(mfrow=c(1, 2))

>plot(Time~Toxicant+Cure, data=rats)

>with(rats, interaction.plot(Toxicant, Cure, Time, trace.label="Cure"))

>with(rats,interaction.plot(Cure, Toxicant, Time, trace.label="Toxicant"))

说明是:

Use box plots and line plots to visualize group differences. There are also two functions specifically designed for visualizing mean differences in ANOVA ayouts. interaction.plot( ) in the base stats package produces plots for two-way interactions.

你先写一个函数,然后在R的界面加载

新建一个脚本:

fun<-function(x){

if(x>=0 &x<=3) y=3*x+2

else y=2*x-0.5*x^2

y

}

保存为fun.R

然后在R界面里

>source("fun.R")

>x<-seq(0,6,0.01) 每隔0.01取一个点

>y<-fun(x)

>plot(x,y)

答:1,打开origin,在输入框中输入自己采集到的数据。其中LongName填的是名称,UnitS填的是单位。2,点击“plot”,选择图表的类型,或者直接在下方选择图表类型。3,然后选择每个名字相对应的坐标轴。4,然后就会生成相对应的图片……