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 [2018/11/20 08:50] – [Splitting a Vector into Groups] hkimscil | r:data_transformations [2019/09/19 18: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 41: | Line 41: | ||
# or | # or | ||
> sapply(g, mean) | > sapply(g, mean) | ||
+ | | ||
+ | 20.95833 23.86667 | ||
# or retain list format | # or retain list format | ||
> lapply(g, mean) | > 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 ====== |
r/data_transformations.1542671407.txt.gz · Last modified: 2018/11/20 08:50 by hkimscil