Created
October 29, 2013 06:51
-
-
Save 14021939/7210098 to your computer and use it in GitHub Desktop.
Rのデータフレーム(data.frame)について ref: http://qiita.com/14021939/items/3436a153119bb88d49df
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 | |
> name <- c('suzuki','sato','yamada') | |
> height <- c('172','165','184') | |
> weight <- c('60','58','75') | |
> users_table <- data.frame(name,height,weight) | |
> users_table | |
name height weight | |
1 suzuki 172 60 | |
2 sato 165 58 | |
3 yamada 184 75 |
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
> users_table[c('name')] | |
name | |
1 suzuki | |
2 sato | |
3 yamada | |
> users_table[c('height')] | |
height | |
1 172 | |
2 165 | |
3 184 | |
> users_table[c('height','weight')] | |
height weight | |
1 172 60 | |
2 165 58 | |
3 184 75 |
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
> users_table$name | |
[1] suzuki sato yamada | |
Levels: sato suzuki yamada |
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
> with(users_table, height[ name == "yamada"]) | |
[1] 184 | |
Levels: 165 172 184 |
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
> users_table | |
name height weight | |
1 suzuki 172 60 | |
2 sato 165 58 | |
3 yamada 184 75 | |
> point <- c(100,30,40) | |
> users_table <- data.frame(users_table, point) | |
> users_table | |
name height weight point | |
1 suzuki 172 60 100 | |
2 sato 165 58 30 | |
3 yamada 184 75 40 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment