Explore Courses Blog Tutorials Interview Questions
+2 votes
in R Programming by (3.5k points)
edited by

How can I remove rows which are duplicate in a column. I have read csv file into R data.frame. For ex.

    platform_external_dbus   303   27    Yahoo                    2
    platform_external_dbus   303   27    Local.files              2
    platform_external_dbus   303   27    host                         2  
    platform_external_dbus   303   27    users.sourcefiles  9    
    platform_external_dbus   303   27    distress                   2

I just want to delete one of the rows above and there is same data in first column.

1 Answer

0 votes
by (2k points)
edited by

Perform this function after isolating your data frame to the columns you want to keep.

# in your example, you only need the first two columns <- unique( data[ , 1:2 ] )
# the third column no longer 'distinguishes' them, 
# so they're duplicates and deleted.

Related questions

+1 vote
1 answer
asked May 29, 2019 in R Programming by Krishna (2.6k points)
+2 votes
2 answers
0 votes
1 answer
asked Jun 18, 2019 in R Programming by Shubham (3.9k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories