dataframe - suppress repeated values in a column in a data.frame in r -


i have simple data.frame

mydf <- read.csv("mydf.csv") mydf                           soc        preferred.term       serious       non.serious            cardiac disorders             dizziness             0                 0            cardiac disorders    dizziness postural             0                 1            cardiac disorders          palpitations             0                 0            cardiac disorders              dyspnoea             0                 1            cardiac disorders     oedema peripheral             0                 0                eye disorders lacrimation increased             0                 3                eye disorders              eye pain             0                 0                eye disorders             mydriasis             0                 0                eye disorders        vision blurred             0                 0                eye disorders     visual impairment             0                 1               oral disorders         dental caries             0                 0               oral disorders        tooth fracture             0                 0 

you can see column titled soc has several repeats. want present table show 1st instance of unique term in soc column. in other words, want table this:

                         soc        preferred.term       serious       non.serious            cardiac disorders             dizziness             0                 0                                 dizziness postural             0                 1                                       palpitations             0                 0                                           dyspnoea             0                 1                                  oedema peripheral             0                 0                eye disorders lacrimation increased             0                 3                                           eye pain             0                 0                                          mydriasis             0                 0                                     vision blurred             0                 0                                  visual impairment             0                 1               oral disorders         dental caries             0                 0                                     tooth fracture             0                 0 

is there simple/quick way modify data.frame remove repeats in 1st column?

alternatively, there type of presentation package in r make table eliminate repeated terms in 1st column?

thank suggestions.

a simple way assumes variable soc sorted , of class character:

mydf$soc[duplicated(mydf$soc)] <- "" 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -