> I have a file data.txt as follows:
>
> Name_1,A,B,C
> Name_2,E,F
> Name_3,I,J,I,K,L,M
>
> My query is how can I keep only the unique elements in each row? For
> example: I want the row 3 to be Name_3,I,J,K,L,M
>
> Please note I don't want the 2nd I to appear.
>
> How can I do this?
Use unique
Hi Ashim,
One way is this, assuming that your data frame is named akdf:
akdf<-t(apply(akdf,1,function(x) return(unique(x)[1:length(x)])))
If you want factors instead of strings, more processing will be required.
Jim
On Mon, Jun 12, 2017 at 3:23 PM, Ashim Kapoor wrote:
> Dear All,
>
> I have a f
2 matches
Mail list logo