str_detect not working in Dplyr

Hi,

I used this code before with no problems; however, the code suddenly doesn't work and the error states that "x could not find function "str_detect"". I've spent nearly three hours trying to remedy this problem to no avail. Could one of you awesome people please help me fix this issue? Dput and codes are below. Thanks in advance!!!

DPUT

structure(list(p__Proteobacteria = c(44.80739, 40.906798, 36.558405, 36.811464, 39.400964, 40.114166, 45.910826, 43.132743, 30.13734, 27.733709, 26.72175, 31.261089), p__Actinobacteria = c(26.8194, 34.65128, 40.904322, 38.847046, 39.446097, 37.52348, 29.881262, 29.250962, 31.783038, 23.64134, 34.917946, 31.307556), p__Acidobacteria = c(8.48037, 6.600244, 5.934457, 6.608856, 5.889835, 7.567146, 5.794511, 6.665685, 10.615547, 10.708667, 8.988121, 11.794193)), class = "data.frame", row.names = c("D15B", "D610B", "D15F", "D610F", "HR15B", "HR610B", "HR15F", "HR610F", "C15B", "C610B", "C15F", "C610F"))

CODES

require(vegan)
require(tidyverse)
require(ggplot2)
#Upload data
phylum.dat <- structure(list(...

#Filter
phylum.dat_subset <- phylum.dat %>% select(p__Proteobacteria, p__Actinobacteria, p__Acidobacteria)

#Diversity
Phylum_Diversity <- diversity(phylum.dat_subset, index = "shannon") #Shannon index

#Put raw data into long format
Phylum_Diversity_long <- as.data.frame (Phylum_Diversity) %>% tibble::rownames_to_column(var = "Plot")

#Add site column (ANOVA needs at least three rownames per site)
long_data_new <- Phylum_Diversity_long %>% mutate(Site = case_when(str_detect(Plot, "D") ~ "Decatur", str_detect(Plot, "H") ~ "Field Station", str_detect(Plot, "C") ~ "Cedartown", TRUE ~ "Unknown"))

#ANOVA
Anova_Results <- aov(Phylum_Diversity ~ Site, data = long_data_new)
summary(Anova_Results)

library(stringr)

I would expect stringr library should be loaded as part of the above tidyverse load.
unless when you required tidyverse, errors were reported to your console ?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.