I have a function I am trying to make in R that looks like this:
diff_abund <- function(Data, Rank, Taxa) {
subset_taxa(Data, Rank == Taxa)
}
da= diff_abund(frbc1_02, Phylum, "Acidobacteria")
And I get the error:
Error in eval(e, x, parent.frame()) : object 'Rank' not found
The problem appears to be with the Rank == Taxa part. If I remove that from the function like so:
diff_abund <- function(Data) {
subset_taxa(Data, Phylum == "Acidobacteria")
}
da= diff_abund(frbc1_02)
The function works normally. The dataset is an S4 object that only works in the package phyloseq. "Rank" is basically a group of vectors ranging from Kingdom down to Species. Not sure what you would call that. Any reason this could be happening? Thank you, Sam