How to combine multiple vectors in one data frame in R ?

Question

Please provide proper example

in progress 0
Shashi Jain 4 years 1 Answer 805 views Newbie 0

Answer ( 1 )

  1. To combine multiple vectors into a data frame, you simply add all vectors as arguments to the data.frame() function, separated by commas. R will automatically create a data frame with the variables that are named the same as the vectors used.
    Eg: Create the following vectors,
    > member amount joined member.data str(member.data)
    ‘data.frame’: 3 obs. of 3 variables:
    $ member : Factor w/ 3 levels “Avantika”,”Aayush”,..: 1 3 2
    $ amount : num 21500 22000 28700
    $ joined: Date, format: “2010-11-01” “2008-03-25” …

    This is how you combine multiple vectors in one data frame in R.

Leave an answer

Browse
Browse