, Iris , 4.3. :
(x[x[,1]==4.3,])
sum(x[x[,1]==4.3,])
x[x[,1]==6.9,]
sum(x[x[,1]==6.9,])
, ,
transform(x,x1=sort(x1))
, , .
4,3 + 3,5 + 1,4 + 0,2 = 9,4
# x1 x2 x3 x4
# 1 4.3 3.5 1.4 0.2
# 2 4.4 3.0 1.4 0.2
# 3 4.4 3.2 1.3 0.2
# 4 4.4 3.1 1.5 0.2
# 5 4.5 3.6 1.4 0.2
If you want to order a data set by increasing the values of the first column without changing the data set, use:
x[order(x$x1),]
# x1 x2 x3 x4
# 14 4.3 3.0 1.1 0.1
# 9 4.4 2.9 1.4 0.2
# 39 4.4 3.0 1.3 0.2
# 43 4.4 3.2 1.3 0.2
# 42 4.5 2.3 1.3 0.3
source
share