Questions tagged [magrittr]

The magrittr package provides operators for chaining R expressions with forward pipes. Do not use this tag for questions which merely contain a pipe operator. Use this tag for questions asking specifically about the behavior of the %>%, %<>%, %$%, or %T>% operators or the convenience functions provided by the package.

To archive its humble aims, magrittr provides a new “pipe”-like operator for , %>%, with which you may pipe a value forward into an expression or function call; something along the lines of x %>% f, rather than f(x). This is not an unknown feature elsewhere; a prime example is the |> operator used extensively in (to say the least) and indeed this – along with Unix pipes – served as a motivation for developing the magrittr package.

In order to get better answers always use this tag together with .

Development version of magrittr is hosted on GitHub.

477 questions
0
votes
1 answer

R call stack detailed inspection

I'm looking for correct way to go with call stack logging. I have functions, which logs their calls to list. s <- list() f <- function(){ s <<- c(s,list(sys.call())) g() } g <- function(){ s <<- c(s,list(sys.call())) 1 } They will be…
jangorecki
  • 16,384
  • 4
  • 79
  • 160
0
votes
1 answer

Renaming Sys.Date() Columns

I want to bind and rename Sys.Date() like this: df <- df %>% cbind(Sys.Date()) %>% rename(week = Sys.Date()) Although I could easily rename the new Sys.Date() column with base R I'd like to pass this through a dplyr/magrittr pipe. But I get the…
emehex
  • 9,874
  • 10
  • 54
  • 100
0
votes
1 answer

Selecting xml_nodes for patent data using library(rvest) and library(xml) in R

Given the following (quasi)xml-structure of EPO's patent Server REPO:
-1
votes
1 answer

R > 4.1 equivalent to magrittr's aliases

In R 4.1 introduced the native forward pipe (|>) that can be used instead of magrittr's %>%. For example, c(1, 2, 3) |> length() is a valid syntax in R > 4.1 and will return 3. magrittr has a collection of aliases. For example, instead of 1 * 2 I…
Raniere Silva
  • 2,527
  • 1
  • 18
  • 34
-1
votes
2 answers

faster way to make new variables containing data frames to be rbinded

I want to make a bunch of new variables a,b,c,d.....z to store tibble data frames. I will then rbind the new variables that store tibble data frames and export them as a csv. How do I do this faster without having to specify the new variables each…
user12165709
-1
votes
1 answer

Where is the documentation on changing R's order of evaluation?

I am new to R and am learning about the dplyr package. In the documentation for %>% I can read about how the packages changes the grammar or the language. For example, The magrittr pipe operators use non-standard evaluation. I would like to learn…
RyeGrain
  • 61
  • 6
-1
votes
1 answer

Copy column data when function unaggregates a single row into multiple in R

I need help in taking an annual total (for each of many initiatives) and breaking that down to each month using a simple division formula. I need to do this for each distinct combination of a few columns while copying down the columns that are…
CGermain
  • 369
  • 7
  • 18
-1
votes
1 answer

Insetting recursive lists with Magrittr piping

How can I inset recursive lists in a way which allows the full modified list to be passed further down the pipe chain? If I have a non recursive list the inset and inset2 functions work, but what about recursive lists? library(magrittr) t1 <-…
NGaffney
  • 1,542
  • 1
  • 15
  • 16
-2
votes
1 answer

Unable to use frollmean and %>%

I want to pipe my data table to frollmean to calculate rolling average of a column. But I am unable to get it work head(mergedDT) date Operating_hours DRIVING_TIME net_hrs workday 1 2018-03-20 110 759 0 TRUE 2…
-2
votes
2 answers

How do I efficiently change the values of a vector in a dataframe based off of a current vector in r?

I am trying to create a new vector "seasons" based off of the months vector already provided in my data. I am using the built-in txhousing dataset; I have already filtered the dataframe to only include information on the city of Houston and have…
Kristen
  • 3
  • 1
  • 1
-2
votes
1 answer

How do magrittr %>% pipes work exactly?

So for the life of me I can’t understand this extremely simple concept. This code looks to me like the code from hell. I was told the pipes are like Russian nesting dolls. Each statement before the pipes apparently feeds into the statement after…
user18139
  • 188
  • 1
  • 3
  • 13
-2
votes
1 answer

What does the symbol "%<>%" do in R?

I see this symbol: %<>%, in someone's R code and could not find out what it does by googling. Can anyone help shed some light on this?
xyy
  • 547
  • 1
  • 5
  • 12
1 2 3
31
32