rfswick / eds221-day9-activities

Materials for EDS 221 Activities - Day 9
0 stars 0 forks source link

problem with the mutate function #1

Open rfswick opened 1 month ago

rfswick commented 1 month ago
mack_creek <- data.frame(
  stringsAsFactors = FALSE,
                                                            length1 = c(58,
                                                                        61,89,58,93,86,
                                                                        107,131,103,117),
                                                            species = c("ONCL","ONCL","ONCL",
                                                                        "ONCL","ONCL",
                                                                        "ONCL","ONCL","ONCL",
                                                                        "ONCL","ONCL"),
                                                               year = c(1987,
                                                                        1987,1987,1987,
                                                                        1987,1987,1987,
                                                                        1987,1987,1987)
                                                 )
mack_creek <- mack_creek_vertebrates %>% 
  clean_names() |>
  select(year:sampledate) %>% 
  filter(section == "CC") %>% 
  mutate(across(where(is.character, tolower))) |>
  drop_na(species) %>% 
  group_by(species) %>% 
  summarize(mean_length_cm = mean(length1, na.rm = TRUE),
            sd_length_cm = sd(length1, na.rm = TRUE)) %>% 
  ungroup()
#> Error in drop_na(select(mack_creek_vertebrates %>% clean_names(), year:sampledate) %>% : could not find function "%>%"

Created on 2024-08-22 with reprex v2.1.1

rfswick commented 1 month ago

mutate(across(where(is.character), tolower))

move tolower outside of the where() function