convert categorical to dummy binary values

R programming language resources Forums Data manipulation convert categorical to dummy binary values

This topic contains 0 replies, has 1 voice, and was last updated by  esra 5 years, 10 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1041

    esra
    Member

    Hi,
    I have the following column from a dataset:
    Vehicle
    Car
    Car
    Car
    Plane
    Plane
    Bus
    Train
    Train
    Bus

    Thus we have 4 different values: Bus, Car, Plane, Train. I want to convert these to binary values automatically and get the following output:
    Vehicle
    0 1 0 0
    0 1 0 0
    0 1 0 0
    0 0 1 0
    0 0 1 0
    1 0 0 0
    0 0 0 1
    0 0 0 1
    1 0 0 0

    How can I get this? (is there a way to do this?) Thank you very much!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.