79130358

Date: 2024-10-27 10:34:46
Score: 2
Natty:
Report link

See the thread here: https://stackoverflow.com/a/79125997/11129415.

Same logic as used by Ben.

#random tree

oldTree <- ape::read.tree(text = "(t2, (t5, (t4, (t6, (t3, t1)))));")
plot(oldTree)

df <- cbind(old.name=oldTree$tip.label, new_name = c(rbind("tip_2", "tip_5", "tip_4","tip_6", "tip_3", "tip_1"))) %>% as.data.frame()

#Get the position of elements --> matching tip labels with the label of the #dataframe

pos_id <-match(oldTree$tip.label, df$old.name)
pos_id #element position
newTree <- oldTree

newTree$tip.label <- df$new_name[pos_id] #here sorting by pos_id
par(mfrow=c(1,2))

plot(oldTree)

plot(newTree)
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Abhi