convert categorical to dummy binary values

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

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.
Scroll to top
Privacy Policy