Hello all,

I have a set B and a dataframe df. I want to name the columns of the
dataframe after the elements of the set B.
For example, for set B with elements {{"P1"}, {"P2"}, {"P3", "P4"}} I want
to create a new dataframe with 3  columns named {"P1"} and {"P2"} and
{"P3","P4"}.

I tried colnames(df)<-(B). But it shows the elements as list, see below:
> colnames(df)
[1] "list(\"P1\")"         "list(\"P2\")"         "list(\"P3\", \"P4\")"


Second part of my question is what is the bests command to extract the
elements of a set?


Thanks,
Neha

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to