Well this is confusing coming from a python background, but mylist[-1]
seems to do the trick. The negative in this case can be read as "except," i.e. take everything except column 1. So colnames(iris)[-1]
works to grab all but the first item.
Oh, and to exclude more items, treat it as a range that is excluded, so colnames(iris)[-2:-4]
would keep only the first and all items after (and including) the fifth one.
For others coming from python, check out this nice slideshow comparing R to python.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…