[R] Using cbind to combine data frames and preserve header/names

Brian Feeny bfeeny at mac.com
Sat Nov 17 06:39:02 CET 2012


I have a dataframe that has a header like so:

class	value1	value2	value3

class is a factor

the actual values in the columns value1, value2 and value3 are 0-255, I wish to binarize these using biclust.
I can do this like so:

binarize(dataframe[,-1])

this will return a dataframe, but then I lose my first column class, so I thought I could combine it like so:

dataframe <- cbind(dataframe$label, binarize(dataframe[,-1]))

but then I lose my header (names).............how can I do the above operation and keep my header in tact?

Basically i just want to binarize everything but the first column (since its a factor column and not numeric).

Thank you for any help you can give me, I am relatively new to R.

Brian



More information about the R-help mailing list