R 语言DataFrame 排序

Sort:
dd
<- data.frame(b = factor(c("Hi","Med","Hi","Low"), levels = c("Low","Med","Hi"), ordered = TRUE), x = c("A","D","A","C"), y = c(8,3,9,9), z = c(1,1,1,2))

sort by column z (descending) then by column b (ascending)
1). dd[with(dd, order(-z, b)),]
2).
dd[ order(-dd[,4], dd[,1]),]

 REngine engine = REngine.GetInstanceFromID("RDotNet");
DataTable table = new DataTable();
engine.EagerEvaluate("myDataFrame <- data.frame('Order' =
c(1,2,3,4,5),'Name' = c('Bob', 'Ryan', 'Mel', 'Mark', 'Ali'))");
DataFrame dataset = engine.EagerEvaluate("myDataFrame").AsDataFrame();
dataGridView_DF.DataSource = dataset;

public enum IrisSpecies
{
   setosa = 1,
   versicolor = 2,
   virginica = 3,
}

[DataFrameRow]
public class IrisData
{
   [DataFrameColumn("Sepal.Length")]
   public double SepalLength { get; set; }
   [DataFrameColumn("Sepal.Width")]
   public double SepalWidth { get; set; }
   [DataFrameColumn("Petal.Length")]
   public double PetalLength { get; set; }
   [DataFrameColumn("Petal.Width")]
   public double PetalWidth { get; set; }
   [DataFrameColumn("Species")]
   public IrisSpecies Species { get; set; }
}

var iris = engine.Evaluate("iris").AsDataFrame();
foreach (var row in iris.GetRows<IrisData>())
{
   Console.WriteLine(row.Species);
}

转载于:https://www.cnblogs.com/wondaz/p/Rsort.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值