Created
June 13, 2016 22:06
-
-
Save kirillseva/46a798623ebd2140421949360afc1d66 to your computer and use it in GitHub Desktop.
I hate rownames
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
R-STABLE> a <- data.frame(a=1:5, b=head(letters, 5)) | |
R-STABLE> a | |
a b | |
1 1 a | |
2 2 b | |
3 3 c | |
4 4 d | |
5 5 e | |
R-STABLE> b <- a[c(1,3,5),] | |
R-STABLE> b | |
a b | |
1 1 a | |
3 3 c | |
5 5 e | |
R-STABLE> str(b) | |
'data.frame': 3 obs. of 2 variables: | |
$ a: int 1 3 5 | |
$ b: chr "a" "c" "e" | |
R-STABLE> rownames(b) | |
[1] "1" "3" "5" | |
R-STABLE> dput(b) | |
structure(list(a = c(1L, 3L, 5L), b = c("a", "c", "e")), .Names = c("a", | |
"b"), row.names = c(1L, 3L, 5L), class = "data.frame") | |
R-STABLE> b[2,] | |
a b | |
3 3 c | |
R-STABLE> b[3,] | |
a b | |
5 5 e | |
R-STABLE> b["3",] | |
a b | |
3 3 c | |
R-STABLE> b["2",] | |
a b | |
NA NA <NA> | |
R-STABLE> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment