r:data_transformations
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| r:data_transformations [2016/10/12 00:29] – [Applying a Function to Groups of Rows] hkimscil | r:data_transformations [2019/09/19 09:23] (current) – [Splitting a Vector into Groups] hkimscil | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| Warning message: | Warning message: | ||
| 패키지 ‘MASS’는 R 버전 3.2.5에서 작성되었습니다 | 패키지 ‘MASS’는 R 버전 3.2.5에서 작성되었습니다 | ||
| - | > split(Cars93$MPG.city, | + | > split(Cars93$MPG.city, |
| $USA | $USA | ||
| [1] 22 19 16 19 16 16 25 25 19 21 18 15 | [1] 22 19 16 19 16 16 25 25 19 21 18 15 | ||
| Line 39: | Line 39: | ||
| [1] 23.86667 | [1] 23.86667 | ||
| > | > | ||
| + | # or | ||
| + | > sapply(g, mean) | ||
| + | | ||
| + | 20.95833 23.86667 | ||
| + | # or retain list format | ||
| + | > lapply(g, mean) | ||
| + | $USA | ||
| + | [1] 20.95833 | ||
| + | |||
| + | $`non-USA` | ||
| + | [1] 23.86667 | ||
| + | |||
| + | |||
| </ | </ | ||
| ====== Applying a Function to Each List Element ====== | ====== Applying a Function to Each List Element ====== | ||
| Line 180: | Line 193: | ||
| < | < | ||
| + | suburbs <- read.csv(" | ||
| </ | </ | ||
| Line 246: | Line 260: | ||
| (Other) | (Other) | ||
| </ | </ | ||
| - | | + | |
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | </ | ||
r/data_transformations.1476232171.txt.gz · Last modified: by hkimscil
