In this article, we will see how to add rows to a DataFrame in R Programming Language. To do this we will use rbind() function. This function in R Language is used to combine specified Vector, Matrix or Data Frame by rows.
Syntax:
rbind(dataframe 1, dataframe 2)
Example 1 :
R
df9 = data.frame (id= c (1,2,3),
name= c ( "karthik" , "bhagiradh" , "kethan" ))
print ( "Original data frame" )
print (df9)
df8 = data.frame (4, "shyam" )
names (df8)= c ( "id" , "name" )
df7= rbind (df9,df8)
print ( "data frame after adding a new row" )
print (df7)
|
Output :

Example 2 :
Python3
df = data.frame( id = c( 1 , 2 , 3 ),
name = c( "maruti suzuki" , "tata" , "ford" ))
print ( "Original data frame" )
print (df)
df1 = data.frame( 4 , "volkswagen" )
names(df1) = c( "id" , "name" )
df2 = rbind(df,df1)
print ( "data frame after adding a new row" )
print (df2)
|
Output :

Example 3:
R
df3 = data.frame (id= c (1,2,3),
name= c ( "Asus" , "HP" , "Acer" ))
print ( "Original data frame" )
print (df3)
df4 = data.frame (4, "Dell" )
names (df4)= c ( "id" , "name" )
df5= rbind (df3,df4)
print ( "data frame after adding a new row" )
print (df5)
|
Output :

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
29 Dec, 2022
Like Article
Save Article