Marc12cram
Marc12cram

Reputation: 1

How to do "arrange" command with newly created variables? (R Lab)

As part of my university studies, I'm using R Lab for my homework and practices. The fact is that we have just learnt how to create new variables in a database (command mutate) but I still don't know how to do the command arrange with the newly created column.

Mainly, I was trying to arrange all the columns based on the results of the new column, but I was unable to...

Thanks for your help :)

Upvotes: 0

Views: 27

Answers (1)

M.Viking
M.Viking

Reputation: 5398

I would "pipe" the mutated date to the arrange command, and name the new column there:

iris %>% 
  mutate(newSpecies=paste0(Petal.Length, "-", Species, "2022")) %>% 
  arrange(newSpecies)

Upvotes: 2

Related Questions