Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Create a list
- lst = [1,3,5,6,7,7]
- #index element at 4-2 (which is 2)
- lst[4-2] # returns 5
- #index element at 2-4 (which is -2) or lst[len(lst)-2]
- lst[4-2] # returns 7
- lst <- c(1,3,5,6,7,7)
- #indexing element at 4-2 (which is 2)
- lst[4-2] # returns 3 (because R indexing starts at 1, not 0)
- [1] 3
- #BUT indexing element at 2-4 (which is -2) does not work,
- #because it means that you are removing the element at index 2, i.e. 3
- lst[2-4] #returns the original list without element at index 2
- [1] 1 5 6 7 7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement