[R] using the function unique(), but asking it to ignore a column of a data.frame
P.Dalgaard at biostat.ku.dk
Mon Jul 9 15:59:01 CEST 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).
> On 7/9/07, hadley wickham <h.wickham at gmail.com> wrote:
>> On 7/9/07, Andrew Yee <yee at post.harvard.edu> wrote:
>>> Take for example the following data.frame:
>>> 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 incomparables=, but
>>> it appears that this funcationality hasn't been incorporated. Is
>>> there a work around for this, i.e. to be able to get unique to only
>>> look at selected columns of a data frame?
>> unique(df[,c("a","c")]) ?
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help