Reputation: 463
I have a large list with 12 elements (dataframes). Each dataframe has the same numer of rows and columns. I would like to subtract value = 150 from each row of the column AMOUNT. This has to be done for all dataframes from the list. Here is an example of the dataframe.
df1
NAME TIME AMOUNT
1 20 456
2 30 345
3 15 122
4 12 267
Upvotes: 4
Views: 11115
Reputation: 887038
We can use lapply
to loop over the list
and subtract 150 from the 'AMOUNT' column
lapply(lst1, transform, AMOUNT = AMOUNT -150)
Or using tidyverse
library(tidyerse)
map(lst1, ~
.x %>%
mutate(AMOUNT = AMOUNT - 150))
Upvotes: 4