How to add column to dataframe in R ? Last Updated : 26 Mar, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we are going to see how to add columns to dataframe in R. First, let's create a sample dataframe. Adding Column to the 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. Create a data frame.Use the $ symbol as shown in the above syntax to add a column to a data frame.Print the updated data frame to see the changes. Example 1: Creating a data frame. R # Creating a data frame with eid , ename,salary as columns df2 = data.frame(eid = c(1, 2, 3), ename = c("karthik", "nikhil", "sravan"), salary = c(50000, 60000, 70000)) # printing the data frame print(df2) Adding a column using $ symbol: R # creating a data frame df2 = data.frame(eid = c(1, 2, 3), ename = c("karthik", "nikhil", "sravan"), salary = c(50000, 60000, 70000)) # adding a new column to the data frame using $ symbol df2$designation = c("data scientist", "senior manager", "HR") # printing the updated data frame print(df2) Example 2: Creating a data frame R # creating a data frame using vectors df1 = data.frame(id = c(1, 2 ,3), name = c("karthik", "nikhil", "sravan")) # printing the data frame print(df1) Adding a column to the data frame R # creating a data frame df1 = data.frame(id = c(1, 2, 3), name = c("karthik", "nikhil", "sravan")) # adding a new column to the data frame using $ symbol df1$branch = c("IT", "CSE", "IT") # printing the updated data frame print(df1) Comment More infoAdvertise with us Next Article How to add column to dataframe in R ? K krishnakarthikeyakhandrika Follow Improve Article Tags : R Language R Programs R-DataFrame R DataFrame-Programs Similar Reads How to Add an Empty Column to DataFrame in R? In this article, we will discuss how to add an empty column to the dataframe in R Programming Language. Add One Empty Column to dataframe Here we are going to add an empty column to the dataframe by assigning column values as NA. Syntax: dataframe[ , 'column_name'] = NA where, dataframe  is the inpu 1 min read How to add suffix to column names in R DataFrame ? Each of the columns in a data frame is defined by a name, known as the column name. It may be of the type of numerical or string value. In this article, we will discuss how to add a suffix to column names in DataFrame in R Programming Language. Method 1 : Using paste() method In order to modify the 4 min read How to add dataframe to dataframe in R ? In this article, we will see how to add dataframe at the end of another dataframe in R Programming Language. Method 1: Using rbind() method The rbind() method in R works only if both the input dataframe contains the same columns with similar lengths and names. The dataframes may have a different num 4 min read How to add a prefix to column names in R DataFrame ? In this article, we will discuss how to add prefixes to column names in DataFrame in R Programming Language. Dataset in use: First SecondThird1a72ab83cv94dsd10Method 1 : Using paste() method In order to modify the column names, the paste function in R can be used. The paste() method, can be used for 4 min read How to add Header to Dataframe in R ? A header necessarily stores the names or headings for each of the columns. It basically helps the user to identify the role of the respective column in the data frame. The top row containing column names is called the header row of the data frame. In this article, we will learn how to add a Header t 3 min read Like