![]() |
VOOZH | about |
In this article, we are going to see how to add columns to dataframe in R. First, let's create a sample dataframe.
We can add a column to a data frame using $ symbol.
syntax: dataframe_name $ column_name = c( value 1,value 2 . . . , value n)
Here c() function is a vector holds values .we can pass any type of data with similar type.
Steps for adding a column to a dataframe.
Example 1: Creating a data frame.
👁 ImageAdding a column using $ symbol:
👁 ImageExample 2: Creating a data frame
👁 ImageAdding a column to the data frame
👁 Image