How to use appy function instead of for loop in a datafreame

for(i in 1:nrow(df_new)){ # loop all new records through existing records:
a=sum(apply(df_unique, 1, function(x) areDuplicateByRules(x, unlist(df_new[i,]))))
cat("Duplicate:", a,"\n")
df_addnew<-rbind(df_addnew, df_new[i,]) #only retain what is unique
Instead of for loop I want to use
apply(dfnew, 1, function(y)
{a = sum(apply(df_unique, 1, function(x) areDuplicateByRules(x, unlist(dfnew[y,]))))
cat("Duplicate:", a,"\n")
if(a == 0){
df_addnew<- rbind(df_addnew, dfnew[y,])}

With an apply function it does not return me a dataframe.
Any help is appreciated.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.