I want to stream a big data table into R LINE BY LINE, and if the current line has a specific condition (lets say the first columns is >15), add the line to a data frame in memory. I have written following code:
count<-1;
Mydata<-NULL;
fin <- FALSE;
while (!fin){
if (count==1){
Myrow=read.delim(pipe('cat /dev/stdin'), header=F,sep="\t",nrows=1);
Mydata<-rbind(Mydata,Myrow);
count<-count+1;
}
else {
count<-count+1;
Myrow=read.delim(pipe('cat /dev/stdin'), header=F,sep="\t",nrows=1);
if (Myrow!=""){
if (MyCONDITION){
Mydata<-rbind(Mydata,Myrow);
}
}
else
{fin<-TRUE}
}
}
print(Mydata);
But I get the error "data not available". Please note that my data is big and I don't want to read it all in once and apply my condition (in this case it was easy).