I am trying to create a loop to calculate relative elemental levels for each fish in this dataset (relative elemental levels will be calculated by x/mean(x) in order to divide each data point by the mean of the entire column. I have all the fish in one dataframe but they can be filtered out by ID (see head of data frame) 1st fish is Ring10_1_2. Here is my current code and the current error I am getting.
raw_data <- read_csv("Hatch5Reg.csv")
fishIDs = unique(raw_data$ID)
Hatch5_Rel_El = list()
for(ID in fishIDs) {
Hatch5_Rel_El[[ID]] = lapply(raw_data %>% filter(ID == ID_) %>% mutate_if(is.numeric),funs(mod = x / mean(x)))
}
#Error in match.fun(FUN) : 'funs(mod = x/mean(x))' is not a function, character or symbol