Search code examples
c#r.net

Object not found in R.net c#


After importing data from csv files, I want to arrange them according to Id numbers for example for the first table:

DataFrame DataIns = engine.Evaluate("DataIns<-read.table('C:/Users/isalah/Desktop/Fichiers_CRM/Fichier_csv/Diagnostic.csv', header=TRUE, sep =';',fill = TRUE)").AsDataFrame();
engine.Evaluate("DataIns[with(DataIns, order(Id)),]").AsExpression();

But this error was shown :

'Error in order(Id) : object 'Id' not found

how resolve it? thanks !


Solution

  • The problem is that you're missing single quotes around Id, so it tries to evaluate it as an object.

    Correct way of doing it is like this:

    engine.Evaluate("DataIns[with(DataIns, order('Id')),]").AsExpression();