What are these symbols characters used for in R

+1 vote

I recently saw a code as shown below:

text_df %>%
  unnest_tokens(word,text_df, to_lower=FALSE)

I am unable to understand the usage of %>% symbol.

Aug 28, 2018 in Data Analytics by Anmol
• 1,780 points
1,362 views

3 answers to this question.

0 votes
The %>% is the pipe operator used to divide the code multiline pipping, this is done just to increase the usability.

It has same functioning as of <- symbol with a addition to take multiline commands
answered Aug 28, 2018 by Abhi
• 3,720 points
0 votes

It is a forward-pipe operator.

You can use it to pass the left-hand side input through the right-hand side operator. In mathematical terms, it is the following operation:

x%>%f which translates to f(x)

Here is a simple example, where I create a vector of values, take the root square of every number and then compute the sum:

c(1,2,3,4) %>% Map(sqrt, .) %>%  Reduce(sum, .)
# The output: [1] 6.146264
It is very useful when you need to apply many different transformations to your data and don’t want to save the intermediate results or have many opening and closing function parentheses.

Consider writing the following:

x %>% impute %>% shuffle %>% pivot
versus the alternative:

pivot(shuffle(impute(x)))
I hope you get the point by now.

Moreover, this technique is very handy when cleaning data.

You can use it in your R session by loading the magrittr package: library(magrittr)

answered Aug 29, 2018 by zombie
• 3,790 points
0 votes
%>% is called a pipe. The process of using pipe is called piping.

Piping is generally used to avoid intermediate variable creation.

It helps in faster execution and easier understanding of opeartions.

A pipe genrally follow below structure -

dataset %>% function1(dataset/list/vector) %>% function2(dataset/list/vector) %>% . . . . . .  

Which follows the operation as output of function1 to function2 and so on..
answered Aug 7, 2019 by anonymous

Related Questions In Data Analytics

0 votes
1 answer

List packages are used for data mining in R?

You can refer to the following packages ...READ MORE

answered Jul 3, 2018 in Data Analytics by DataKing99
• 8,250 points
1,595 views
0 votes
1 answer

What are the top packages in R for data visualization?

These are the top R packages used ...READ MORE

answered Aug 26, 2019 in Data Analytics by Cherukuri
• 33,030 points
900 views
0 votes
1 answer

What is the standard naming convention for the variables in R?

Use of period separator e.g. product.prices <- c(12.01, ...READ MORE

answered Apr 25, 2018 in Data Analytics by shams
• 3,670 points
669 views
0 votes
2 answers

What are the rules to define a variable name in R programming language?

The same rules almost follow for all ...READ MORE

answered Aug 26, 2019 in Data Analytics by anonymous
• 33,030 points
15,173 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
1,224 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
5,909 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,154 views
0 votes
1 answer

Plotting multiple graphs on the same page in R

If you want to plot 4 graphs ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,440 views
0 votes
1 answer

What are the important skills to have in Python with regard to data analysis?

The following are some of the important ...READ MORE

answered Aug 20, 2018 in Data Analytics by Abhi
• 3,720 points
4,576 views
0 votes
1 answer

Which package is used to do data import in R and Python and How do you import SAS data?

We can do data import using multiple ...READ MORE

answered Aug 24, 2018 in Data Analytics by Abhi
• 3,720 points
948 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP