Skip to content
Prev 369738 / 398503 Next

Keep only those values in a row in a data frame which occur only once.

Use unique() on each row and pad with NA?

Example:
uniq10 <- function(x, L=10) {
	u <- unique(x)
	c(u, rep(NA, L-length(u)) )
}

as.data.frame(  t( apply(tmp, 1, uniq10)  )  )

assuming tmp is the name of your initial data frame.

S Ellison




*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
Message-ID: <1A8C1289955EF649A09086A153E267240BA3DB200B@GBTEDVPEXCMB04.corp.lgc-group.com>
In-Reply-To: <CAC8=1er_BvCWEFjQ6x-8pEfuGiM7G-hDQ3nQW6ZtuNzE3Uz_9g@mail.gmail.com>