[英]How to draw a binary linear equation in R?
Now I have a binary linear equation z = wx1 - (1-w)x2 , and w varys from 0 to 1 in 0.1 intervals.现在我有一个二元线性方程z = wx1 - (1-w)x2 ,并且w在 0.1 的间隔内从 0 变化到 1。 With two variables x1 and x2, I want to plot this equation with R.
有两个变量 x1 和 x2,我想用 R 绘制这个方程。
With constraints x1<=19266669.5
, and x2<=52575341.065
有约束
x1<=19266669.5
和x2<=52575341.065
I tried the code below, but it didn't work.我尝试了下面的代码,但是没有用。
w=seq(0,1,0.1)
x1<=19266669.5
x2<=52575341.065
z = w*x1 - (1-w)*x2
plot(w,z,type="l",lwd=2,col="red",main="z = w*x1 - (1-w)*x2")
How should I improve the code?我应该如何改进代码? Thank you in advance!
先感谢您!
Your are assigning values so, it is an assignment error, you should use first (based on your snippet) the operator <- Then to plot use <=, or whatever relational operator you want.您正在分配值,所以这是一个分配错误,您应该首先(根据您的代码段)使用运算符<-然后绘制使用 <= 或您想要的任何关系运算符。
Assignments operators:赋值运算符:
x <- value
x <<- value<="" code="">
value -> x
value ->> x
x = value
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.