Taxonomy Table Using R Studio

Hi! After a little trial and error, I was able to create a taxonomy table using qiime2R in R Studio, which looks great. My only concern now is that I want the taxonomic classification in the legend to just have the specific taxa classification that I'm focusing on for that specific chart (i.e., Phyla, Family, etc.). My current code includes the entire string of the classification from Kingdom to whatever classification I'm going to. Here is an example of the code I'm using at the Phyla level:

taxonomy<-read_qza("taxonomy.qza")$data %>% parse_taxonomy()
taxonomy$Kingdom <- gsub("^d__", "", taxonomy$Kingdom)

taxasums<-summarize_taxa(SVs, taxonomy)$Phylum
taxa_barplot(taxasums, metadata, "Treatment")

Any advice is greatly appreciated!

Hey, did you get this figured out?

When I make taxonomy for bar plots, I usually make a new data frame column and add in just the levels that I want.

# base R
taxonomy$newColumn <- paste(taxonomy$Kingdom, taxonomy$Phylum)

# using tidyverse
taxonomy <- taxonomy %>%
  mutate(newColumn = paste(Kingdom, Phylum))