Wed Dec 12, 2018 9:47 pm
Login Register Lost Password? Contact Us


hpcc dataset and R data frame mapping

Questions and comments related to the rHPCC integration plugin

Thu Nov 16, 2017 4:16 pm Change Time Zone

hpcc dataset gets converted to data frames when passed in as parameter but, all columns in dataframes are as list. e.g. cyl becomes a list instead of vector producing the error
System error: 0: Rembed: Rcpp error: invalid type (list) for variable 'cyl'

Code: Select all
IMPORT R,ML;
mtcarsrec := RECORD
  real8     mpg;
  unsigned1 cyl;
  real8     disp;
  unsigned2 hp;
  real8     drat;
  real8     wt;
  real8     qsec;
  boolean   vs;
  boolean   am;
  unsigned1 gear;
  unsigned1 carb;
END;
hpccmtcars:= dataset([{21.0,6,160.0,110,3.90,2.620,16.46,TRUE,FALSE,4,4}],mtcarsrec);

STRING run_r(dataset(RECORDOF(hpccmtcars)) ds):=EMBED(R)
rslt=  function (ds)
{
    my_modl = lm(cyl ~ ., data = ds)
    coef(my_modl)
}
rawToChar(serialize(rslt(ds), NULL,ascii=TRUE),multiple = FALSE)
ENDEMBED;
run_r( hpccmtcars );


please help if I am missing something
balajisampath
 
Posts: 63
Joined: Mon Jul 22, 2013 6:29 pm

Mon Jan 08, 2018 9:03 am Change Time Zone

Unfortunately I'm not really very familiar with R, and in particular the differences between lists and vectors and when you would want one rather than the other. Ideally the R embed plugin would have been written by an R expert (but we don't have one).

If someone can help me understand the differences and why a vector is what is wanted in this situation, I can take a look at changing it (though I'll also have to be a little careful that I don't break any existing code).
richardkchapman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 108
Joined: Fri Jun 17, 2011 8:59 am


Return to R Plugin

Who is online

Users browsing this forum: No registered users and 1 guest