[R] Converting column of strings to boolean

Pete Brecknock Peter.Brecknock at bp.com
Sun Jan 27 00:27:45 CET 2013

domcastro wrote
> Hi
> I'm trying to convert a column of strings (nominal types) to a set of
> boolean / binary / logical values. For example, in the column there is
> red, blue, green and yellow. There are 100 rows and each has a colour. I
> want to convert the column to 4 columns: red, blue, green,yellow and then
> either 1 or 0 put in the relevant row.
> Thanks

maybe model.matrix will help ....

# d is my understanding of your data
model.matrix(~d -1)



View this message in context: http://r.789695.n4.nabble.com/Converting-column-of-strings-to-boolean-tp4656739p4656741.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list