[R] using the function unique(), but asking it to ignore a column of a data.frame

2007-07-09 Thread Andrew Yee
Take for example the following data.frame: a-c(1,1,5) b-c(3,2,3) c-c(5,1,5) sample.data.frame-data.frame(a=a,b=b,c=c) I'd like to be able to use unique(sample.data.frame), but have unique() ignore column a when determining the unique elements. However, I figured that this would be setting for

Re: [R] using the function unique(), but asking it to ignore a column of a data.frame

2007-07-09 Thread hadley wickham
On 7/9/07, Andrew Yee [EMAIL PROTECTED] wrote: Take for example the following data.frame: a-c(1,1,5) b-c(3,2,3) c-c(5,1,5) sample.data.frame-data.frame(a=a,b=b,c=c) I'd like to be able to use unique(sample.data.frame), but have unique() ignore column a when determining the unique

Re: [R] using the function unique(), but asking it to ignore a column of a data.frame

2007-07-09 Thread Andrew Yee
Thanks. But in this specific case, I would like the output to include all three columns, including the ignored column (in this case, I'd like it to ignore column a). Thanks, Andrew On 7/9/07, hadley wickham [EMAIL PROTECTED] wrote: On 7/9/07, Andrew Yee [EMAIL PROTECTED] wrote: Take for

Re: [R] using the function unique(), but asking it to ignore a column of a data.frame

2007-07-09 Thread Peter Dalgaard
Andrew Yee wrote: Thanks. But in this specific case, I would like the output to include all three columns, including the ignored column (in this case, I'd like it to ignore column a). df[!duplicated(df[,c(a,c)]),] or perhaps df[!duplicated(df[-2]),] Thanks, Andrew On 7/9/07, hadley

Re: [R] using the function unique(), but asking it to ignore a column of a data.frame

2007-07-09 Thread hadley wickham
On 7/9/07, Peter Dalgaard [EMAIL PROTECTED] wrote: Andrew Yee wrote: Thanks. But in this specific case, I would like the output to include all three columns, including the ignored column (in this case, I'd like it to ignore column a). df[!duplicated(df[,c(a,c)]),] or perhaps

Re: [R] using the function unique(), but asking it to ignore a column of a data.frame

2007-07-09 Thread Prof Brian Ripley
On Mon, 9 Jul 2007, Andrew Yee wrote: Thanks. But in this specific case, I would like the output to include all three columns, including the ignored column (in this case, I'd like it to ignore column a). sample.data.frame[!duplicated(sample.data.frame[-1]), ] (index to exclude columns as

Re: [R] using the function unique(), but asking it to ignore a column of a data.frame

2007-07-09 Thread Andrew Yee
Thanks, this works perfectly. On 7/9/07, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Mon, 9 Jul 2007, Andrew Yee wrote: Thanks. But in this specific case, I would like the output to include all three columns, including the ignored column (in this case, I'd like it to ignore column a).