0 votes
1 view
in R Programming by (50.5k points)

In my data frame, I am having 3 columns and 1000+ rows that are being generated from R. The data types of the first two columns are strings and the last characters are similar in some columns. I want to filter out data only from non-similar rows.

    Z=

    AAA.aa BBB.aa 0.9

    AAA.aa BBB.bb 0.8

    CCC.cc DDD.cc 0.7

    CCC.cc BBB.bb 0.8

I want my output as:

    AAA.aa BBB.bb 0.8

    CCC.cc BBB.bb 0.8

Any help would be highly appreciated.

1 Answer

0 votes
by (108k points)

I think the following code will work for you:

    filter <- apply(Z,MARGIN = 1,function(x){

                                             paste(x,collapse = "")

                                             }) %>% duplicated

    Z[filter,]

If you are a beginner and want to know more about R then do check out the R programming course.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...