Microsoft R rxDataStep - RowSelection

356 views Asked by At

I am new to Microsoft Revr. I am facing a small problem in the below code

FILTER<-"TRANS > 0"                                                  
max_rows_cols <- 100000000000000000000 

data1 <- rxDataStep(inData = data1,transformObjects=list(Filter=FILTER),
rowSelection =**noquote(Filter)** ,overwrite = TRUE,maxRowsByCols=max_rows_cols)

I get the value of FILTER at run time.

Is Something wrong with the row selection value?

Looking forward to help on this?

2

There are 2 answers

0
akrun On

We can use eval(parse

library(RevoScaleR)
rxDataStep(inData = data1, transformObjects=list(Filter=FILTER),
                  rowSelection = eval(parse(text=Filter)))
#  Rows Read: 5, Total Rows Processed: 5, Total Chunk Time: 0.003 seconds 
#  Col1 TRANS
#1    3     1
#2    4     3
#3    5     2

data

data1 <- data.frame(Col1 = 1:5, TRANS = c(-5, -4, 1, 3, 2))
FILTER<-"TRANS > 0"     
2
Hong Ooi On

The rowSelection argument should be an expression giving the rows to keep. You need to parse (but not evaluate) your filter text:

filterExpr <- parse(text=FILTER)
df <- rxDataStep(data1, rowSelection=filterExpr, maxRowsByCols=NULL)

Note that if you want to turn off the dataset size check, set maxRowsByCols=NULL.