[R] Removing duplicated values

Ista Zahn istazahn at gmail.com
Tue Dec 11 15:40:10 CET 2012


Hi,

On Tue, Dec 11, 2012 at 9:23 AM, Neotropical bat risk assessments
<neotropical.bats at gmail.com> wrote:
> Hi all,
>
> I have been away from R for far too many months and have two questions.
> One is likely simple, but not found under help or in many of the available R
> ref., books.
>
> 1.  How does one save the results of an analysis from the main console to a
> file without the need to copy and paste?

Depends on what you are saving and what format you want to save it to. See

?sink
?write.table
?cat

and the data import/export manual

>
> 2. What tools (possibly Plyr or reshape) can be used to remove duplicated
> entries in a data matrix?
> I have some 650,000 records in a table (text values for most fields) that
> were imported form a number of sources and now I find that table is inflated
> by anywhere from 2-20 duplicated entries.

mat <- mat[!duplicated(mat)]

where 'mat' is the name of your matrix

Best,
Ista

 I need to remove all dupes and
> only retain unique values.  Excel is choking on this so I thought R would be
> a better and more efficient option.
>
>
> Tnx,
>
> Bruce
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list