Re: [R] How to delete Identical columns

2013-03-28 Thread Charles Berry
Charles Berry ucsd.edu> writes: [snip] > > Katherine Gobin 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 > > Details >

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 wrote: > Katherine Gobin yahoo.com> writes: > > > > > Dear R forum > > > > Suppose I have a data.frame > > > > Say. > >

Re: [R] How to delete Identical columns

2013-03-28 Thread Charles Berry
Katherine Gobin 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 ?unique Det

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 y

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 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 = c(15, 21, 14, 21, 14, 38

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 Katherine Gobin
ichner wrote: From: Gerrit Eichner Subject: Re: [R] How to delete Identical columns To: "Katherine Gobin" Cc: r-help@r-project.org Date: Thursday, 28 March, 2013, 8:58 AM Hi, Katherine, IF the naming scheme of the columns of your data frame is consistently and if duplicated column

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 and if duplicated columns appear THEN (something like) df[ -grep( "\\.", names( df))] could help. (But it's maybe more efficient to avoid - a priori - producing duplicated columns, if the data frame is l

[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