in a dataframe where the concentration column goes 10, 5, 2, 1 repeatedly, reverse the order of the concentration column in r

Here's how you can reverse the order of the concentration column in a dataframe using dplyr package in R:

main.r
library(dplyr)

df <- df %>%
  mutate(concentration = rev(concentration))
74 chars
5 lines

In the above code, we are using the mutate() function from dplyr package to modify the concentration column in our dataframe df. The rev() function is applied to concentration column to reverse the order of the values in it. The %>% operator is used for piping the output of one function to the input of the next function.

gistlibby LogSnag