Union() & union_all() functions in Dplyr package in R Last Updated : 21 Jul, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss union() and union_all() functions using Dplyr package in the R programming language. Dataframes in use: Example: R program to create data frames with college student data and display them R # create dataframe1 with college # 1 data data1=data.frame(id=c(1,2,3,4,5), name=c('sravan','ojaswi','bobby', 'gnanesh','rohith')) # create dataframe1 with college # 2 data data2=data.frame(id=c(1,2,3,4,5,6,7), name=c('sravan','ojaswi','bobby', 'gnanesh','rohith', 'pinkey','dhanush')) # display data1 print(data1) # display data2 print(data2) Output: For both of these functions to work successfully, dplyr package should be installed and imported to the working space. union() function union() is used to return all the elements when two data frames are combined. It doesn't repeat duplicate values. Syntax: union(dataframe1,dataframe2) Example: R program to perform union among two dataframes. R library(dplyr) # create dataframe1 with college 1 data data1=data.frame(id=c(1,2,3,4,5), name=c('sravan','ojaswi','bobby','gnanesh','rohith')) # create dataframe1 with college 2 data data2=data.frame(id=c(1,2,3,4,5,6,7), name=c('sravan','ojaswi','bobby','gnanesh','rohith', 'pinkey','dhanush')) # union of the two dataframes print(union(data1,data2)) Output: union_all() function This will return all the data from both dataframes. Unlike union, it will return duplicate data also. Syntax: union_all(dataframe1,dataframe2) Example: R program to perform union_all operation R library(dplyr) # create dataframe1 with college # 1 data data1=data.frame(id=c(1,2,3,4,5), name=c('sravan','ojaswi','bobby', 'gnanesh','rohith')) # create dataframe1 with college # 2 data data2=data.frame(id=c(1,2,3,4,5,6,7), name=c('sravan','ojaswi','bobby', 'gnanesh','rohith', 'pinkey','dhanush')) # union_all of the two dataframes print(union_all(data1,data2)) Output: Comment More infoAdvertise with us Next Article Union() & union_all() functions in Dplyr package in R S sravankumar_171fa07058 Follow Improve Article Tags : R Language R Dplyr Similar Reads Joining Data in R with Dplyr Package In this article, we will be looking at the different methods of joining data with the dplyr in the R programming language. We need to load the dplyr package. Type the below commands - Install - install.packages("dplyr") Load - library("dplyr") Method 1: Using  inner join In this method of joining d 5 min read Windows Function in R using Dplyr Aggregation functions in R are used to take a bunch of values and give us output as a single value. Some of the examples of aggregation methods are the sum and mean. Windows functions in R provide a variation to the aggregation methods in the sense that they return the number of outputs equivalent t 7 min read Case when statement in R Dplyr Package using case_when() Function This article focuses upon the case when statement in the R programming language using the case_when() function from the Dplyr package. Case when is a mechanism using which we can vectorize a bunch of if and else if statements. In simple words, using a case when statement we evaluate a condition expr 4 min read cumall(), cumany() & cummean() R Functions of dplyr Package In this article, we will discuss about cumall(), cummany(), and cummean() functions in R Programming Language. Which are available in dplyr() package. We have to install and load dplyr package. Install - install.packages("dplyr") Load - library("dplyr")cumall() This function will check whether the f 3 min read Apply a function to each group using Dplyr in R In this article, we are going to learn how to apply a function to each group using dplyr in the R programming language. The dplyr package in R is used for data manipulations and modifications. The package can be downloaded and installed into the working space using the following command : install.p 4 min read Like