0

I am trying to loop the names of a phyloseq objects with the variable otu_table with them. This is my code.

ps_groups <- c("ps_10B","ps_10D", "ps_11D", "ps_12D", "ps_13D",     "ps_14D", "ps_15D", "ps_16D", "ps_17B",
           "ps_17D", "ps_18B", "ps_18D", "ps_19B", "ps_19D",     "ps_1B", "ps_1D", "ps_20D", "ps_21B",
           "ps_21D", "ps_22D", "ps_23B", "ps_23D", "ps_24B",     "ps_24D", "ps_25D", "ps_26D", "ps_27B",
           "ps_27D", "ps_28B", "ps_28D", "ps_29B", "ps_29D",     "ps_2B", "ps_2D", "ps_30B", "ps_31B",
           "ps_32B", "ps_33B", "ps_34B", "ps_35B", "ps_36B",     "ps_37B", "ps_38B", "ps_39B", "ps_3B",
           "ps_3D", "ps_43B", "ps_47B", "ps_4D", "ps_5B", "ps_5D",     "ps_6B", "ps_6D", "ps_7D", "ps_8B",
           "ps_8D", "ps_9D")

for(i in ps_groups) {
  name <- paste("colMax_", i, sep = "")
  assign(name, lapply(data.frame(ps_groups@otu_table), max))
}

However I get the following error. no applicable method for @ applied to an object of class "character"

If I were to write the command for each sample it would look like the following:

colMax_calf<-lapply(data.frame(ps_5B@otu_table), max)

Thanks in advance!

I am expecting the command to loop through the name vector and generate the corresponding objects.

0 Answers0