Bert,
Is it important that you end up with a data frame? If not, it would be
very easy to generate a list with the unique values for each column. For
example:
df <- data.frame(v1 = sample(5, 20, T), v2 = sample(7, 20, T),
v3 = sample(9, 20, T), v4 = sample(11, 20, T))
lapply(df, unique)
Jean
"Bert Jacobs" <bert.jacobs@figurestofacts.be> wrote on
07/20/2012 02:37:37
PM:
> Hi,
>
> I was wondering what the best way is to create a new dataframe based on
an> existing dataframe with only the unique available levels for each column
(22> columns in total) in it.
>
> If some columns have less unique values than others, then those columns
can> be filled with blanks for the remaining part. Is it possible to make it
a> generic function, which is independent from the column names?
>
> Thx for helping me out.
>
>
>
> Kind regards,
>
> Bert
[[alternative HTML version deleted]]