Last active
March 24, 2022 17:07
-
-
Save chelseaparlett/6650469fd800367eddbb37033e78a122 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
# create named list | |
l <- list(x = data.frame(a = rnorm(10), b = rnorm(10)), | |
y = data.frame(a = rnorm(10), b = rnorm(10)), | |
z = data.frame(a = rnorm(10), b = rnorm(10))) | |
for (i in names(l)){ | |
if (i %in% c("x", "y")){ # if the name of the list item is in a specified sublist | |
l[[i]] <- l[[i]] %>% mutate(c = a + 1) # then do the mutate | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment