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.
Answer ( 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.