[R] How to delete Identical columns

2013-03-28 Thread Katherine Gobin
Dear R forum Suppose I have a data.frame df = data.frame(id = c(1:6), x = c(15, 21, 14, 21, 14, 38), y = c(36, 38, 55, 11, 5, 18), x.1 = c(15, 21, 14, 21, 14, 38), z = c(D, B, A, F, H, P)) df   id  x  y    x.1 z 1  1 15 36  15 D 2  2 21 38  21 B 3  3 14 55  14 A 4  4 21 11  21 F 5  5 14  5 

Re: [R] How to delete Identical columns

2013-03-28 Thread Gerrit Eichner
Hi, Katherine, IF the naming scheme of the columns of your data frame is consistently stringwithoutdot and stringwithoutdot.number if duplicated columns appear THEN (something like) df[ -grep( \\., names( df))] could help. (But it's maybe more efficient to avoid - a priori - producing

Re: [R] How to delete Identical columns

2013-03-28 Thread Katherine Gobin
...@math.uni-giessen.de wrote: From: Gerrit Eichner gerrit.eich...@math.uni-giessen.de Subject: Re: [R] How to delete Identical columns To: Katherine Gobin katherine_go...@yahoo.com Cc: r-help@r-project.org Date: Thursday, 28 March, 2013, 8:58 AM Hi, Katherine, IF the naming scheme of the columns

Re: [R] How to delete Identical columns

2013-03-28 Thread Anthony Damico
this might screw up the column classes of some of your columns, but it could be enough for what you're doing :) # start with a data frame with duplicate columns v - data.frame(id = c(1:6), x = c(15, 21, 14, 21, 14, 38), y = c(36, 38, 55, 11, 5, 18), x.1 = c(15, 21, 14, 21, 14, 38), z = c(D, B,

Re: [R] How to delete Identical columns

2013-03-28 Thread arun
  5 H #6  6 38 18 P A.K. - Original Message - From: Katherine Gobin katherine_go...@yahoo.com To: r-help@r-project.org Cc: Sent: Thursday, March 28, 2013 4:39 AM Subject: [R] How to delete Identical columns Dear R forum Suppose I have a data.frame df = data.frame(id = c(1:6), x

Re: [R] How to delete Identical columns

2013-03-28 Thread David Winsemius
On Mar 28, 2013, at 1:39 AM, Katherine Gobin wrote: Dear R forum Suppose I have a data.frame df = data.frame(id = c(1:6), x = c(15, 21, 14, 21, 14, 38), y = c(36, 38, 55, 11, 5, 18), x.1 = c(15, 21, 14, 21, 14, 38), z = c(D, B, A, F, H, P)) df id x yx.1 z 1 1 15 36

Re: [R] How to delete Identical columns

2013-03-28 Thread Charles Berry
Katherine Gobin katherine_gobin at yahoo.com writes: Dear R forum Suppose I have a data.frame Say. [snip] How to automatically identify and retain only one column (in this example column x) among the identical columns besides other non-identical columns (viz. id, y and z). See

Re: [R] How to delete Identical columns

2013-03-28 Thread Bert Gunter
Yes, but the elephant in the room is: Define: Identical. If you do not know why this is an elephant, see FAQ 7.31. -- Bert On Thu, Mar 28, 2013 at 8:40 AM, Charles Berry ccbe...@ucsd.edu wrote: Katherine Gobin katherine_gobin at yahoo.com writes: Dear R forum Suppose I have a

Re: [R] How to delete Identical columns

2013-03-28 Thread Charles Berry
Charles Berry ccberry at ucsd.edu writes: [snip] Katherine Gobin katherine_gobin at yahoo.com writes: How to automatically identify and retain only one column (in this example column x) among the identical columns besides other non-identical columns (viz. id, y and z). See ?unique