R dataframe sorted by a column

Usage scenarios: randomly generated value as is, so no sequence x distinction (plotting Figure 1), so to use to sort the data re-mapping (mapping Figure II)
x <-rnorm (n-, 0 ,. 5)
E <-rnorm (n-, 0, 0.01)
Y <-10 0.8 + X. 3 + X ^ 2 + 0.1 X ^ + E. 3
Y1 <-11.7 + 0.538
X + 2.93 * X 2 * X + 0.097 . 3
DATA2 <-data.frame (X, Y1)
DATA3 <-DATA2 [Sort (DATA2 x , i n d e x . r e t in r n = T R The E ) x,index.return=TRUE) ix,]
plot(x,y)
#lines(x,y1)
lines(data3 x , d a t a 3 x,data3 Y1, COL = '# fe8463', LWD = 2)
Figure 1:Figure I
Figure 2:Here Insert Picture Description

Published 20 original articles · won praise 3 · Views 3533

Guess you like

Origin blog.csdn.net/qq_41858657/article/details/103097906