[R] How to duplicate rows in dataframe?

Olaf Mersmann olafm at tako.de
Mon Dec 13 21:19:49 CET 2004


Hi Christian,

cstrato wrote:
> Dear all:
> 
*snip*
> 
> However consider the following vector:
>    x <- c(13,32,13,24,46,24,24)
> Now I want to get the dataframe in the order of the rows
> defined in x, i.e. the dataframe contains duplicate rows.
> One way to achieve this would be to use rbind in a for-loop.
> 
> My question is:
> Is there an easier and - more important - faster way to
> obtain the dataframe as defined in x?

?unique
?sort

HTH
Olaf




More information about the R-help mailing list