a question about notation...

Hello, I am just learning about assigning etc and am still trying to understanding the reason/approach. Something that has slightly confused me is code such as this:

example_df  <- table_name %>%
  select(col_name_a, col_name_b) %>% 
  unite(new_col_name c("col_name_c", "col_name_d"), sep = " ")

I am not a programmer although I am also not new to things such as VBA (where code is fairly structured in terms of variables, assignments, functions, etc) although the way R does things seems fairly unique; and while I suspect it is a more rational way of doing things (once you understand it) I am still a little confused about what is happening (in terms of how R/Rstudio chooses the bit to do first etc - is there a BIDMAS type of sequence)? PS I am not asking for an explanation of the unite or select functions (this is purely a question about how to think about coding in RStudio in terms of sequential functions etc)

Thank you in advance for your comments

Here is how I explain it in class. If you take three pieces of pipe and connect them, you now have one long piece of pipe. The result of that one long pipe on the RHS is assigned to the LHS.

Of course, this may not be an answer to the question you asked.

1 Like

In your example, the order of operations is left to right: first select, then unite.

More generally, R does obey BODMAS, and then there are additional orderings such as and precedes or.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.