I know that you can subset NAs from a specific column with:
subset(df,column=="")
And I also built a function integrating the former in:
subset.grep<-function(selfrom,where,q){
if (q==""){
result<-subset(selfrom,where=="")
} else{
for(i in q)
result<-selfrom[ grep(i, selfrom[[where]]), ]
}
return(result)
}
This way I can subset a data frame given a query, even when an element of the query is not present in the targeted data frame.
It works when q!="", but when q=="", it does't appear to be working properly in my function.
Aucun commentaire:
Enregistrer un commentaire