ePoQ
ePoQ

Reputation: 463

Call a result as a column name

I have a clustering result coded has best.seed To be clear if the result of best.seed is uc.4 and I wrote :

for(i in 1:16) {
      assign(paste0("Factor", i), row.names(subset(res.uc.df, uc.4 == i)))
    }

My loop is working. But, if I try to call the best.seed or best.seed[1] result instead that is not working. Result are empty

for(i in 1:16) {
      assign(paste0("Factor", i), row.names(subset(res.uc.df, best.seed == i)))
    }

Upvotes: 0

Views: 47

Answers (1)

Cath
Cath

Reputation: 24074

for(i in 1:16) {
      assign(paste0("Factor", i), row.names(subset(res.uc.df, get(best.seed) == i)))
    }

should work.

Upvotes: 1

Related Questions